babylon.gui.js 687 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816
  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. <<<<<<< HEAD
  11. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__) {
  12. =======
  13. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_tools__) {
  14. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  15. return /******/ (function(modules) { // webpackBootstrap
  16. /******/ // The module cache
  17. /******/ var installedModules = {};
  18. /******/
  19. /******/ // The require function
  20. /******/ function __webpack_require__(moduleId) {
  21. /******/
  22. /******/ // Check if module is in cache
  23. /******/ if(installedModules[moduleId]) {
  24. /******/ return installedModules[moduleId].exports;
  25. /******/ }
  26. /******/ // Create a new module (and put it into the cache)
  27. /******/ var module = installedModules[moduleId] = {
  28. /******/ i: moduleId,
  29. /******/ l: false,
  30. /******/ exports: {}
  31. /******/ };
  32. /******/
  33. /******/ // Execute the module function
  34. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  35. /******/
  36. /******/ // Flag the module as loaded
  37. /******/ module.l = true;
  38. /******/
  39. /******/ // Return the exports of the module
  40. /******/ return module.exports;
  41. /******/ }
  42. /******/
  43. /******/
  44. /******/ // expose the modules object (__webpack_modules__)
  45. /******/ __webpack_require__.m = modules;
  46. /******/
  47. /******/ // expose the module cache
  48. /******/ __webpack_require__.c = installedModules;
  49. /******/
  50. /******/ // define getter function for harmony exports
  51. /******/ __webpack_require__.d = function(exports, name, getter) {
  52. /******/ if(!__webpack_require__.o(exports, name)) {
  53. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  54. /******/ }
  55. /******/ };
  56. /******/
  57. /******/ // define __esModule on exports
  58. /******/ __webpack_require__.r = function(exports) {
  59. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  60. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  61. /******/ }
  62. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  63. /******/ };
  64. /******/
  65. /******/ // create a fake namespace object
  66. /******/ // mode & 1: value is a module id, require it
  67. /******/ // mode & 2: merge all properties of value into the ns
  68. /******/ // mode & 4: return value when already ns object
  69. /******/ // mode & 8|1: behave like require
  70. /******/ __webpack_require__.t = function(value, mode) {
  71. /******/ if(mode & 1) value = __webpack_require__(value);
  72. /******/ if(mode & 8) return value;
  73. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  74. /******/ var ns = Object.create(null);
  75. /******/ __webpack_require__.r(ns);
  76. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  77. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  78. /******/ return ns;
  79. /******/ };
  80. /******/
  81. /******/ // getDefaultExport function for compatibility with non-harmony modules
  82. /******/ __webpack_require__.n = function(module) {
  83. /******/ var getter = module && module.__esModule ?
  84. /******/ function getDefault() { return module['default']; } :
  85. /******/ function getModuleExports() { return module; };
  86. /******/ __webpack_require__.d(getter, 'a', getter);
  87. /******/ return getter;
  88. /******/ };
  89. /******/
  90. /******/ // Object.prototype.hasOwnProperty.call
  91. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  92. /******/
  93. /******/ // __webpack_public_path__
  94. /******/ __webpack_require__.p = "";
  95. /******/
  96. /******/
  97. /******/ // Load entry module and return exports
  98. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  99. /******/ })
  100. /************************************************************************/
  101. /******/ ({
  102. /***/ "../../node_modules/tslib/tslib.es6.js":
  103. /*!***********************************************************!*\
  104. <<<<<<< HEAD
  105. !*** D:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  106. =======
  107. !*** C:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  108. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  109. \***********************************************************/
  110. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  111. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112. "use strict";
  113. __webpack_require__.r(__webpack_exports__);
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  133. /*! *****************************************************************************
  134. Copyright (c) Microsoft Corporation. All rights reserved.
  135. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  136. this file except in compliance with the License. You may obtain a copy of the
  137. License at http://www.apache.org/licenses/LICENSE-2.0
  138. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  139. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  140. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  141. MERCHANTABLITY OR NON-INFRINGEMENT.
  142. See the Apache Version 2.0 License for specific language governing permissions
  143. and limitations under the License.
  144. ***************************************************************************** */
  145. /* global Reflect, Promise */
  146. var extendStatics = function(d, b) {
  147. extendStatics = Object.setPrototypeOf ||
  148. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  149. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  150. return extendStatics(d, b);
  151. };
  152. function __extends(d, b) {
  153. extendStatics(d, b);
  154. function __() { this.constructor = d; }
  155. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  156. }
  157. var __assign = function() {
  158. __assign = Object.assign || function __assign(t) {
  159. for (var s, i = 1, n = arguments.length; i < n; i++) {
  160. s = arguments[i];
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  162. }
  163. return t;
  164. }
  165. return __assign.apply(this, arguments);
  166. }
  167. function __rest(s, e) {
  168. var t = {};
  169. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  170. t[p] = s[p];
  171. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  172. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  173. t[p[i]] = s[p[i]];
  174. return t;
  175. }
  176. function __decorate(decorators, target, key, desc) {
  177. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  178. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  179. 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;
  180. return c > 3 && r && Object.defineProperty(target, key, r), r;
  181. }
  182. function __param(paramIndex, decorator) {
  183. return function (target, key) { decorator(target, key, paramIndex); }
  184. }
  185. function __metadata(metadataKey, metadataValue) {
  186. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  187. }
  188. function __awaiter(thisArg, _arguments, P, generator) {
  189. return new (P || (P = Promise))(function (resolve, reject) {
  190. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  191. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  192. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  193. step((generator = generator.apply(thisArg, _arguments || [])).next());
  194. });
  195. }
  196. function __generator(thisArg, body) {
  197. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  198. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  199. function verb(n) { return function (v) { return step([n, v]); }; }
  200. function step(op) {
  201. if (f) throw new TypeError("Generator is already executing.");
  202. while (_) try {
  203. 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;
  204. if (y = 0, t) op = [op[0] & 2, t.value];
  205. switch (op[0]) {
  206. case 0: case 1: t = op; break;
  207. case 4: _.label++; return { value: op[1], done: false };
  208. case 5: _.label++; y = op[1]; op = [0]; continue;
  209. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  210. default:
  211. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  212. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  213. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  214. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  215. if (t[2]) _.ops.pop();
  216. _.trys.pop(); continue;
  217. }
  218. op = body.call(thisArg, _);
  219. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  220. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  221. }
  222. }
  223. function __exportStar(m, exports) {
  224. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  225. }
  226. function __values(o) {
  227. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  228. if (m) return m.call(o);
  229. return {
  230. next: function () {
  231. if (o && i >= o.length) o = void 0;
  232. return { value: o && o[i++], done: !o };
  233. }
  234. };
  235. }
  236. function __read(o, n) {
  237. var m = typeof Symbol === "function" && o[Symbol.iterator];
  238. if (!m) return o;
  239. var i = m.call(o), r, ar = [], e;
  240. try {
  241. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  242. }
  243. catch (error) { e = { error: error }; }
  244. finally {
  245. try {
  246. if (r && !r.done && (m = i["return"])) m.call(i);
  247. }
  248. finally { if (e) throw e.error; }
  249. }
  250. return ar;
  251. }
  252. function __spread() {
  253. for (var ar = [], i = 0; i < arguments.length; i++)
  254. ar = ar.concat(__read(arguments[i]));
  255. return ar;
  256. }
  257. function __await(v) {
  258. return this instanceof __await ? (this.v = v, this) : new __await(v);
  259. }
  260. function __asyncGenerator(thisArg, _arguments, generator) {
  261. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  262. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  263. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  264. 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); }); }; }
  265. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  266. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  267. function fulfill(value) { resume("next", value); }
  268. function reject(value) { resume("throw", value); }
  269. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  270. }
  271. function __asyncDelegator(o) {
  272. var i, p;
  273. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  274. 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; }
  275. }
  276. function __asyncValues(o) {
  277. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  278. var m = o[Symbol.asyncIterator], i;
  279. 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);
  280. 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); }); }; }
  281. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  282. }
  283. function __makeTemplateObject(cooked, raw) {
  284. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  285. return cooked;
  286. };
  287. function __importStar(mod) {
  288. if (mod && mod.__esModule) return mod;
  289. var result = {};
  290. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  291. result.default = mod;
  292. return result;
  293. }
  294. function __importDefault(mod) {
  295. return (mod && mod.__esModule) ? mod : { default: mod };
  296. }
  297. /***/ }),
  298. /***/ "../../node_modules/webpack/buildin/global.js":
  299. /*!***********************************!*\
  300. !*** (webpack)/buildin/global.js ***!
  301. \***********************************/
  302. /*! no static exports found */
  303. /***/ (function(module, exports) {
  304. var g;
  305. // This works in non-strict mode
  306. g = (function() {
  307. return this;
  308. })();
  309. try {
  310. // This works if eval is allowed (see CSP)
  311. g = g || new Function("return this")();
  312. } catch (e) {
  313. // This works if the window reference is available
  314. if (typeof window === "object") g = window;
  315. }
  316. // g can still be undefined, but nothing to do about it...
  317. // We return undefined, instead of nothing here, so it's
  318. // easier to handle this case. if(!global) { ...}
  319. module.exports = g;
  320. /***/ }),
  321. /***/ "./2D/adtInstrumentation.ts":
  322. /*!**********************************!*\
  323. !*** ./2D/adtInstrumentation.ts ***!
  324. \**********************************/
  325. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  327. "use strict";
  328. __webpack_require__.r(__webpack_exports__);
  329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  330. <<<<<<< HEAD
  331. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  332. =======
  333. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  334. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  335. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
  336. /**
  337. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  338. */
  339. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  340. /**
  341. * Instantiates a new advanced dynamic texture instrumentation.
  342. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  343. * @param texture Defines the AdvancedDynamicTexture to instrument
  344. */
  345. function AdvancedDynamicTextureInstrumentation(
  346. /**
  347. * Define the instrumented AdvancedDynamicTexture.
  348. */
  349. texture) {
  350. this.texture = texture;
  351. this._captureRenderTime = false;
  352. this._renderTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. this._captureLayoutTime = false;
  354. this._layoutTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  355. // Observers
  356. this._onBeginRenderObserver = null;
  357. this._onEndRenderObserver = null;
  358. this._onBeginLayoutObserver = null;
  359. this._onEndLayoutObserver = null;
  360. }
  361. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  362. // Properties
  363. /**
  364. * Gets the perf counter used to capture render time
  365. */
  366. get: function () {
  367. return this._renderTime;
  368. },
  369. enumerable: true,
  370. configurable: true
  371. });
  372. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  373. /**
  374. * Gets the perf counter used to capture layout time
  375. */
  376. get: function () {
  377. return this._layoutTime;
  378. },
  379. enumerable: true,
  380. configurable: true
  381. });
  382. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  383. /**
  384. * Enable or disable the render time capture
  385. */
  386. get: function () {
  387. return this._captureRenderTime;
  388. },
  389. set: function (value) {
  390. var _this = this;
  391. if (value === this._captureRenderTime) {
  392. return;
  393. }
  394. this._captureRenderTime = value;
  395. if (value) {
  396. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  397. _this._renderTime.beginMonitoring();
  398. });
  399. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  400. _this._renderTime.endMonitoring(true);
  401. });
  402. }
  403. else {
  404. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  405. this._onBeginRenderObserver = null;
  406. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  407. this._onEndRenderObserver = null;
  408. }
  409. },
  410. enumerable: true,
  411. configurable: true
  412. });
  413. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  414. /**
  415. * Enable or disable the layout time capture
  416. */
  417. get: function () {
  418. return this._captureLayoutTime;
  419. },
  420. set: function (value) {
  421. var _this = this;
  422. if (value === this._captureLayoutTime) {
  423. return;
  424. }
  425. this._captureLayoutTime = value;
  426. if (value) {
  427. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  428. _this._layoutTime.beginMonitoring();
  429. });
  430. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  431. _this._layoutTime.endMonitoring(true);
  432. });
  433. }
  434. else {
  435. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  436. this._onBeginLayoutObserver = null;
  437. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  438. this._onEndLayoutObserver = null;
  439. }
  440. },
  441. enumerable: true,
  442. configurable: true
  443. });
  444. /**
  445. * Dispose and release associated resources.
  446. */
  447. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  448. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  449. this._onBeginRenderObserver = null;
  450. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  451. this._onEndRenderObserver = null;
  452. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  453. this._onBeginLayoutObserver = null;
  454. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  455. this._onEndLayoutObserver = null;
  456. this.texture = null;
  457. };
  458. return AdvancedDynamicTextureInstrumentation;
  459. }());
  460. /***/ }),
  461. /***/ "./2D/advancedDynamicTexture.ts":
  462. /*!**************************************!*\
  463. !*** ./2D/advancedDynamicTexture.ts ***!
  464. \**************************************/
  465. /*! exports provided: AdvancedDynamicTexture */
  466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  467. "use strict";
  468. __webpack_require__.r(__webpack_exports__);
  469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  470. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  471. <<<<<<< HEAD
  472. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  473. =======
  474. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  475. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  476. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  477. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  478. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  479. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  480. /**
  481. * Class used to create texture to support 2D GUI elements
  482. * @see http://doc.babylonjs.com/how_to/gui
  483. */
  484. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  485. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AdvancedDynamicTexture, _super);
  486. /**
  487. * Creates a new AdvancedDynamicTexture
  488. * @param name defines the name of the texture
  489. * @param width defines the width of the texture
  490. * @param height defines the height of the texture
  491. * @param scene defines the hosting scene
  492. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  493. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  494. */
  495. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  496. if (width === void 0) { width = 0; }
  497. if (height === void 0) { height = 0; }
  498. if (generateMipMaps === void 0) { generateMipMaps = false; }
  499. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  500. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA) || this;
  501. _this._isDirty = false;
  502. /** @hidden */
  503. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  504. /** @hidden */
  505. _this._lastControlOver = {};
  506. /** @hidden */
  507. _this._lastControlDown = {};
  508. /** @hidden */
  509. _this._capturingControl = {};
  510. /** @hidden */
  511. _this._linkedControls = new Array();
  512. _this._isFullscreen = false;
  513. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  514. _this._idealWidth = 0;
  515. _this._idealHeight = 0;
  516. _this._useSmallestIdeal = false;
  517. _this._renderAtIdealSize = false;
  518. _this._blockNextFocusCheck = false;
  519. _this._renderScale = 1;
  520. _this._cursorChanged = false;
  521. /**
  522. * Define type to string to ensure compatibility across browsers
  523. * Safari doesn't support DataTransfer constructor
  524. */
  525. _this._clipboardData = "";
  526. /**
  527. * Observable event triggered each time an clipboard event is received from the rendering canvas
  528. */
  529. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  530. /**
  531. * Observable event triggered each time a pointer down is intercepted by a control
  532. */
  533. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  534. /**
  535. * Observable event triggered before layout is evaluated
  536. */
  537. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  538. /**
  539. * Observable event triggered after the layout was evaluated
  540. */
  541. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  542. /**
  543. * Observable event triggered before the texture is rendered
  544. */
  545. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  546. /**
  547. * Observable event triggered after the texture was rendered
  548. */
  549. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  550. /**
  551. * Gets or sets a boolean defining if alpha is stored as premultiplied
  552. */
  553. _this.premulAlpha = false;
  554. _this._useInvalidateRectOptimization = true;
  555. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  556. _this._invalidatedRectangle = null;
  557. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  558. /** @hidden */
  559. _this.onClipboardCopy = function (rawEvt) {
  560. var evt = rawEvt;
  561. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  562. _this.onClipboardObservable.notifyObservers(ev);
  563. evt.preventDefault();
  564. };
  565. /** @hidden */
  566. _this.onClipboardCut = function (rawEvt) {
  567. var evt = rawEvt;
  568. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  569. _this.onClipboardObservable.notifyObservers(ev);
  570. evt.preventDefault();
  571. };
  572. /** @hidden */
  573. _this.onClipboardPaste = function (rawEvt) {
  574. var evt = rawEvt;
  575. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  576. _this.onClipboardObservable.notifyObservers(ev);
  577. evt.preventDefault();
  578. };
  579. scene = _this.getScene();
  580. if (!scene || !_this._texture) {
  581. return _this;
  582. }
  583. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  584. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  585. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  586. if (!_this._focusedControl) {
  587. return;
  588. }
  589. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  590. _this._focusedControl.processKeyboard(info.event);
  591. }
  592. info.skipOnPointerObservable = true;
  593. });
  594. _this._rootContainer._link(_this);
  595. _this.hasAlpha = true;
  596. if (!width || !height) {
  597. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  598. _this._onResize();
  599. }
  600. _this._texture.isReady = true;
  601. return _this;
  602. }
  603. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  604. /**
  605. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  606. * Useful when you want more antialiasing
  607. */
  608. get: function () {
  609. return this._renderScale;
  610. },
  611. set: function (value) {
  612. if (value === this._renderScale) {
  613. return;
  614. }
  615. this._renderScale = value;
  616. this._onResize();
  617. },
  618. enumerable: true,
  619. configurable: true
  620. });
  621. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  622. /** Gets or sets the background color */
  623. get: function () {
  624. return this._background;
  625. },
  626. set: function (value) {
  627. if (this._background === value) {
  628. return;
  629. }
  630. this._background = value;
  631. this.markAsDirty();
  632. },
  633. enumerable: true,
  634. configurable: true
  635. });
  636. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  637. /**
  638. * Gets or sets the ideal width used to design controls.
  639. * The GUI will then rescale everything accordingly
  640. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  641. */
  642. get: function () {
  643. return this._idealWidth;
  644. },
  645. set: function (value) {
  646. if (this._idealWidth === value) {
  647. return;
  648. }
  649. this._idealWidth = value;
  650. this.markAsDirty();
  651. this._rootContainer._markAllAsDirty();
  652. },
  653. enumerable: true,
  654. configurable: true
  655. });
  656. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  657. /**
  658. * Gets or sets the ideal height used to design controls.
  659. * The GUI will then rescale everything accordingly
  660. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  661. */
  662. get: function () {
  663. return this._idealHeight;
  664. },
  665. set: function (value) {
  666. if (this._idealHeight === value) {
  667. return;
  668. }
  669. this._idealHeight = value;
  670. this.markAsDirty();
  671. this._rootContainer._markAllAsDirty();
  672. },
  673. enumerable: true,
  674. configurable: true
  675. });
  676. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  677. /**
  678. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  679. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  680. */
  681. get: function () {
  682. return this._useSmallestIdeal;
  683. },
  684. set: function (value) {
  685. if (this._useSmallestIdeal === value) {
  686. return;
  687. }
  688. this._useSmallestIdeal = value;
  689. this.markAsDirty();
  690. this._rootContainer._markAllAsDirty();
  691. },
  692. enumerable: true,
  693. configurable: true
  694. });
  695. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  696. /**
  697. * Gets or sets a boolean indicating if adaptive scaling must be used
  698. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  699. */
  700. get: function () {
  701. return this._renderAtIdealSize;
  702. },
  703. set: function (value) {
  704. if (this._renderAtIdealSize === value) {
  705. return;
  706. }
  707. this._renderAtIdealSize = value;
  708. this._onResize();
  709. },
  710. enumerable: true,
  711. configurable: true
  712. });
  713. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  714. /**
  715. * Gets the underlying layer used to render the texture when in fullscreen mode
  716. */
  717. get: function () {
  718. return this._layerToDispose;
  719. },
  720. enumerable: true,
  721. configurable: true
  722. });
  723. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  724. /**
  725. * Gets the root container control
  726. */
  727. get: function () {
  728. return this._rootContainer;
  729. },
  730. enumerable: true,
  731. configurable: true
  732. });
  733. /**
  734. * Returns an array containing the root container.
  735. * This is mostly used to let the Inspector introspects the ADT
  736. * @returns an array containing the rootContainer
  737. */
  738. AdvancedDynamicTexture.prototype.getChildren = function () {
  739. return [this._rootContainer];
  740. };
  741. /**
  742. * Will return all controls that are inside this texture
  743. * @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
  744. * @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
  745. * @return all child controls
  746. */
  747. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  748. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  749. };
  750. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  751. /**
  752. * Gets or sets the current focused control
  753. */
  754. get: function () {
  755. return this._focusedControl;
  756. },
  757. set: function (control) {
  758. if (this._focusedControl == control) {
  759. return;
  760. }
  761. if (this._focusedControl) {
  762. this._focusedControl.onBlur();
  763. }
  764. if (control) {
  765. control.onFocus();
  766. }
  767. this._focusedControl = control;
  768. },
  769. enumerable: true,
  770. configurable: true
  771. });
  772. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  773. /**
  774. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  775. */
  776. get: function () {
  777. if (!this.layer) {
  778. return true;
  779. }
  780. return (!this.layer.isBackground);
  781. },
  782. set: function (value) {
  783. if (!this.layer) {
  784. return;
  785. }
  786. if (this.layer.isBackground === !value) {
  787. return;
  788. }
  789. this.layer.isBackground = !value;
  790. },
  791. enumerable: true,
  792. configurable: true
  793. });
  794. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  795. /**
  796. * Gets or set information about clipboardData
  797. */
  798. get: function () {
  799. return this._clipboardData;
  800. },
  801. set: function (value) {
  802. this._clipboardData = value;
  803. },
  804. enumerable: true,
  805. configurable: true
  806. });
  807. /**
  808. * Get the current class name of the texture useful for serialization or dynamic coding.
  809. * @returns "AdvancedDynamicTexture"
  810. */
  811. AdvancedDynamicTexture.prototype.getClassName = function () {
  812. return "AdvancedDynamicTexture";
  813. };
  814. /**
  815. * Function used to execute a function on all controls
  816. * @param func defines the function to execute
  817. * @param container defines the container where controls belong. If null the root container will be used
  818. */
  819. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  820. if (!container) {
  821. container = this._rootContainer;
  822. }
  823. func(container);
  824. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  825. var child = _a[_i];
  826. if (child.children) {
  827. this.executeOnAllControls(func, child);
  828. continue;
  829. }
  830. func(child);
  831. }
  832. };
  833. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  834. /**
  835. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  836. */
  837. get: function () {
  838. return this._useInvalidateRectOptimization;
  839. },
  840. set: function (value) {
  841. this._useInvalidateRectOptimization = value;
  842. },
  843. enumerable: true,
  844. configurable: true
  845. });
  846. /**
  847. * Invalidates a rectangle area on the gui texture
  848. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  849. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  850. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  851. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  852. */
  853. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  854. if (!this._useInvalidateRectOptimization) {
  855. return;
  856. }
  857. if (!this._invalidatedRectangle) {
  858. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  859. }
  860. else {
  861. // Compute intersection
  862. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  863. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  864. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  865. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  866. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  867. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  868. }
  869. };
  870. /**
  871. * Marks the texture as dirty forcing a complete update
  872. */
  873. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  874. this._isDirty = true;
  875. };
  876. /**
  877. * Helper function used to create a new style
  878. * @returns a new style
  879. * @see http://doc.babylonjs.com/how_to/gui#styles
  880. */
  881. AdvancedDynamicTexture.prototype.createStyle = function () {
  882. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  883. };
  884. /**
  885. * Adds a new control to the root container
  886. * @param control defines the control to add
  887. * @returns the current texture
  888. */
  889. AdvancedDynamicTexture.prototype.addControl = function (control) {
  890. this._rootContainer.addControl(control);
  891. return this;
  892. };
  893. /**
  894. * Removes a control from the root container
  895. * @param control defines the control to remove
  896. * @returns the current texture
  897. */
  898. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  899. this._rootContainer.removeControl(control);
  900. return this;
  901. };
  902. /**
  903. * Release all resources
  904. */
  905. AdvancedDynamicTexture.prototype.dispose = function () {
  906. var scene = this.getScene();
  907. if (!scene) {
  908. return;
  909. }
  910. this._rootCanvas = null;
  911. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  912. if (this._resizeObserver) {
  913. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  914. }
  915. if (this._pointerMoveObserver) {
  916. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  917. }
  918. if (this._pointerObserver) {
  919. scene.onPointerObservable.remove(this._pointerObserver);
  920. }
  921. if (this._preKeyboardObserver) {
  922. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  923. }
  924. if (this._canvasPointerOutObserver) {
  925. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  926. }
  927. if (this._layerToDispose) {
  928. this._layerToDispose.texture = null;
  929. this._layerToDispose.dispose();
  930. this._layerToDispose = null;
  931. }
  932. this._rootContainer.dispose();
  933. this.onClipboardObservable.clear();
  934. this.onControlPickedObservable.clear();
  935. this.onBeginRenderObservable.clear();
  936. this.onEndRenderObservable.clear();
  937. this.onBeginLayoutObservable.clear();
  938. this.onEndLayoutObservable.clear();
  939. _super.prototype.dispose.call(this);
  940. };
  941. AdvancedDynamicTexture.prototype._onResize = function () {
  942. var scene = this.getScene();
  943. if (!scene) {
  944. return;
  945. }
  946. // Check size
  947. var engine = scene.getEngine();
  948. var textureSize = this.getSize();
  949. var renderWidth = engine.getRenderWidth() * this._renderScale;
  950. var renderHeight = engine.getRenderHeight() * this._renderScale;
  951. if (this._renderAtIdealSize) {
  952. if (this._idealWidth) {
  953. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  954. renderWidth = this._idealWidth;
  955. }
  956. else if (this._idealHeight) {
  957. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  958. renderHeight = this._idealHeight;
  959. }
  960. }
  961. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  962. this.scaleTo(renderWidth, renderHeight);
  963. this.markAsDirty();
  964. if (this._idealWidth || this._idealHeight) {
  965. this._rootContainer._markAllAsDirty();
  966. }
  967. }
  968. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  969. };
  970. /** @hidden */
  971. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  972. var engine = scene.getEngine();
  973. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  974. };
  975. /**
  976. * Get screen coordinates for a vector3
  977. * @param position defines the position to project
  978. * @param worldMatrix defines the world matrix to use
  979. * @returns the projected position
  980. */
  981. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  982. var scene = this.getScene();
  983. if (!scene) {
  984. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  985. }
  986. var globalViewport = this._getGlobalViewport(scene);
  987. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  988. projectedPosition.scaleInPlace(this.renderScale);
  989. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  990. };
  991. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  992. if (this._layerToDispose) {
  993. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  994. return;
  995. }
  996. }
  997. if (this._isFullscreen && this._linkedControls.length) {
  998. var scene = this.getScene();
  999. if (!scene) {
  1000. return;
  1001. }
  1002. var globalViewport = this._getGlobalViewport(scene);
  1003. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1004. var control = _a[_i];
  1005. if (!control.isVisible) {
  1006. continue;
  1007. }
  1008. var mesh = control._linkedMesh;
  1009. if (!mesh || mesh.isDisposed()) {
  1010. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1011. control.linkWithMesh(null);
  1012. });
  1013. continue;
  1014. }
  1015. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1016. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1017. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1018. control.notRenderable = true;
  1019. continue;
  1020. }
  1021. control.notRenderable = false;
  1022. // Account for RenderScale.
  1023. projectedPosition.scaleInPlace(this.renderScale);
  1024. control._moveToProjectedPosition(projectedPosition);
  1025. }
  1026. }
  1027. if (!this._isDirty && !this._rootContainer.isDirty) {
  1028. return;
  1029. }
  1030. this._isDirty = false;
  1031. this._render();
  1032. this.update(true, this.premulAlpha);
  1033. };
  1034. AdvancedDynamicTexture.prototype._render = function () {
  1035. var textureSize = this.getSize();
  1036. var renderWidth = textureSize.width;
  1037. var renderHeight = textureSize.height;
  1038. var context = this.getContext();
  1039. context.font = "18px Arial";
  1040. context.strokeStyle = "white";
  1041. // Layout
  1042. this.onBeginLayoutObservable.notifyObservers(this);
  1043. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1044. this._rootContainer._layout(measure, context);
  1045. this.onEndLayoutObservable.notifyObservers(this);
  1046. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1047. // Clear
  1048. if (this._invalidatedRectangle) {
  1049. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1050. }
  1051. else {
  1052. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1053. }
  1054. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1055. if (this._background) {
  1056. context.save();
  1057. context.fillStyle = this._background;
  1058. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1059. context.restore();
  1060. }
  1061. // Render
  1062. this.onBeginRenderObservable.notifyObservers(this);
  1063. this._rootContainer._render(context, this._invalidatedRectangle);
  1064. this.onEndRenderObservable.notifyObservers(this);
  1065. this._invalidatedRectangle = null;
  1066. };
  1067. /** @hidden */
  1068. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1069. if (this._rootCanvas) {
  1070. this._rootCanvas.style.cursor = cursor;
  1071. this._cursorChanged = true;
  1072. }
  1073. };
  1074. /** @hidden */
  1075. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1076. this._lastControlDown[pointerId] = control;
  1077. this.onControlPickedObservable.notifyObservers(control);
  1078. };
  1079. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1080. var scene = this.getScene();
  1081. if (!scene) {
  1082. return;
  1083. }
  1084. var engine = scene.getEngine();
  1085. var textureSize = this.getSize();
  1086. if (this._isFullscreen) {
  1087. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1088. var viewport = camera.viewport;
  1089. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1090. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1091. }
  1092. if (this._capturingControl[pointerId]) {
  1093. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1094. return;
  1095. }
  1096. this._cursorChanged = false;
  1097. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1098. this._changeCursor("");
  1099. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1100. if (this._lastControlOver[pointerId]) {
  1101. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1102. delete this._lastControlOver[pointerId];
  1103. }
  1104. }
  1105. }
  1106. if (!this._cursorChanged) {
  1107. this._changeCursor("");
  1108. }
  1109. this._manageFocus();
  1110. };
  1111. /** @hidden */
  1112. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1113. for (var pointerId in list) {
  1114. if (!list.hasOwnProperty(pointerId)) {
  1115. continue;
  1116. }
  1117. var lastControlOver = list[pointerId];
  1118. if (lastControlOver === control) {
  1119. delete list[pointerId];
  1120. }
  1121. }
  1122. };
  1123. /** @hidden */
  1124. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1125. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1126. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1127. };
  1128. /** Attach to all scene events required to support pointer events */
  1129. AdvancedDynamicTexture.prototype.attach = function () {
  1130. var _this = this;
  1131. var scene = this.getScene();
  1132. if (!scene) {
  1133. return;
  1134. }
  1135. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1136. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1137. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1138. return;
  1139. }
  1140. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1141. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1142. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1143. return;
  1144. }
  1145. if (!scene) {
  1146. return;
  1147. }
  1148. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1149. var engine = scene.getEngine();
  1150. if (!camera) {
  1151. tempViewport.x = 0;
  1152. tempViewport.y = 0;
  1153. tempViewport.width = engine.getRenderWidth();
  1154. tempViewport.height = engine.getRenderHeight();
  1155. }
  1156. else {
  1157. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1158. }
  1159. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1160. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1161. _this._shouldBlockPointer = false;
  1162. // Do picking modifies _shouldBlockPointer
  1163. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1164. // Avoid overwriting a true skipOnPointerObservable to false
  1165. if (_this._shouldBlockPointer) {
  1166. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1167. }
  1168. });
  1169. this._attachToOnPointerOut(scene);
  1170. };
  1171. /**
  1172. * Register the clipboard Events onto the canvas
  1173. */
  1174. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1175. self.addEventListener("copy", this.onClipboardCopy, false);
  1176. self.addEventListener("cut", this.onClipboardCut, false);
  1177. self.addEventListener("paste", this.onClipboardPaste, false);
  1178. };
  1179. /**
  1180. * Unregister the clipboard Events from the canvas
  1181. */
  1182. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1183. self.removeEventListener("copy", this.onClipboardCopy);
  1184. self.removeEventListener("cut", this.onClipboardCut);
  1185. self.removeEventListener("paste", this.onClipboardPaste);
  1186. };
  1187. /**
  1188. * Connect the texture to a hosting mesh to enable interactions
  1189. * @param mesh defines the mesh to attach to
  1190. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1191. */
  1192. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1193. var _this = this;
  1194. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1195. var scene = this.getScene();
  1196. if (!scene) {
  1197. return;
  1198. }
  1199. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1200. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1201. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1202. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1203. return;
  1204. }
  1205. var pointerId = pi.event.pointerId || 0;
  1206. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1207. var uv = pi.pickInfo.getTextureCoordinates();
  1208. if (uv) {
  1209. var size = _this.getSize();
  1210. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1211. }
  1212. }
  1213. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1214. if (_this._lastControlDown[pointerId]) {
  1215. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1216. }
  1217. delete _this._lastControlDown[pointerId];
  1218. if (_this.focusedControl) {
  1219. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1220. var canMoveFocus = true;
  1221. if (friendlyControls) {
  1222. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1223. var control = friendlyControls_1[_i];
  1224. // Same host, no need to keep the focus
  1225. if (_this === control._host) {
  1226. continue;
  1227. }
  1228. // Different hosts
  1229. var otherHost = control._host;
  1230. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1231. canMoveFocus = false;
  1232. break;
  1233. }
  1234. }
  1235. }
  1236. if (canMoveFocus) {
  1237. _this.focusedControl = null;
  1238. }
  1239. }
  1240. }
  1241. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1242. if (_this._lastControlOver[pointerId]) {
  1243. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1244. }
  1245. delete _this._lastControlOver[pointerId];
  1246. }
  1247. });
  1248. mesh.enablePointerMoveEvents = supportPointerMove;
  1249. this._attachToOnPointerOut(scene);
  1250. };
  1251. /**
  1252. * Move the focus to a specific control
  1253. * @param control defines the control which will receive the focus
  1254. */
  1255. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1256. this.focusedControl = control;
  1257. this._lastPickedControl = control;
  1258. this._blockNextFocusCheck = true;
  1259. };
  1260. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1261. if (this._blockNextFocusCheck) {
  1262. this._blockNextFocusCheck = false;
  1263. this._lastPickedControl = this._focusedControl;
  1264. return;
  1265. }
  1266. // Focus management
  1267. if (this._focusedControl) {
  1268. if (this._focusedControl !== this._lastPickedControl) {
  1269. if (this._lastPickedControl.isFocusInvisible) {
  1270. return;
  1271. }
  1272. this.focusedControl = null;
  1273. }
  1274. }
  1275. };
  1276. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1277. var _this = this;
  1278. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1279. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1280. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1281. }
  1282. delete _this._lastControlOver[pointerEvent.pointerId];
  1283. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1284. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1285. delete _this._lastControlDown[pointerEvent.pointerId];
  1286. }
  1287. });
  1288. };
  1289. // Statics
  1290. /**
  1291. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1292. * @param mesh defines the mesh which will receive the texture
  1293. * @param width defines the texture width (1024 by default)
  1294. * @param height defines the texture height (1024 by default)
  1295. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1296. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1297. * @returns a new AdvancedDynamicTexture
  1298. */
  1299. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1300. if (width === void 0) { width = 1024; }
  1301. if (height === void 0) { height = 1024; }
  1302. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1303. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1304. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1305. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1306. material.backFaceCulling = false;
  1307. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1308. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1309. if (onlyAlphaTesting) {
  1310. material.diffuseTexture = result;
  1311. material.emissiveTexture = result;
  1312. result.hasAlpha = true;
  1313. }
  1314. else {
  1315. material.emissiveTexture = result;
  1316. material.opacityTexture = result;
  1317. }
  1318. mesh.material = material;
  1319. result.attachToMesh(mesh, supportPointerMove);
  1320. return result;
  1321. };
  1322. /**
  1323. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1324. * In this mode the texture will rely on a layer for its rendering.
  1325. * This allows it to be treated like any other layer.
  1326. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1327. * LayerMask is set through advancedTexture.layer.layerMask
  1328. * @param name defines name for the texture
  1329. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1330. * @param scene defines the hsoting scene
  1331. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1332. * @returns a new AdvancedDynamicTexture
  1333. */
  1334. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1335. if (foreground === void 0) { foreground = true; }
  1336. if (scene === void 0) { scene = null; }
  1337. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1338. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1339. // Display
  1340. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1341. layer.texture = result;
  1342. result._layerToDispose = layer;
  1343. result._isFullscreen = true;
  1344. // Attach
  1345. result.attach();
  1346. return result;
  1347. };
  1348. return AdvancedDynamicTexture;
  1349. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1350. /***/ }),
  1351. /***/ "./2D/controls/button.ts":
  1352. /*!*******************************!*\
  1353. !*** ./2D/controls/button.ts ***!
  1354. \*******************************/
  1355. /*! exports provided: Button */
  1356. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1357. "use strict";
  1358. __webpack_require__.r(__webpack_exports__);
  1359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1360. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1361. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1362. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1363. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1364. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1365. /**
  1366. * Class used to create 2D buttons
  1367. */
  1368. var Button = /** @class */ (function (_super) {
  1369. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1370. /**
  1371. * Creates a new Button
  1372. * @param name defines the name of the button
  1373. */
  1374. function Button(name) {
  1375. var _this = _super.call(this, name) || this;
  1376. _this.name = name;
  1377. _this.thickness = 1;
  1378. _this.isPointerBlocker = true;
  1379. var alphaStore = null;
  1380. _this.pointerEnterAnimation = function () {
  1381. alphaStore = _this.alpha;
  1382. _this.alpha -= 0.1;
  1383. };
  1384. _this.pointerOutAnimation = function () {
  1385. if (alphaStore !== null) {
  1386. _this.alpha = alphaStore;
  1387. }
  1388. };
  1389. _this.pointerDownAnimation = function () {
  1390. _this.scaleX -= 0.05;
  1391. _this.scaleY -= 0.05;
  1392. };
  1393. _this.pointerUpAnimation = function () {
  1394. _this.scaleX += 0.05;
  1395. _this.scaleY += 0.05;
  1396. };
  1397. return _this;
  1398. }
  1399. Object.defineProperty(Button.prototype, "image", {
  1400. /**
  1401. * Returns the image part of the button (if any)
  1402. */
  1403. get: function () {
  1404. return this._image;
  1405. },
  1406. enumerable: true,
  1407. configurable: true
  1408. });
  1409. Object.defineProperty(Button.prototype, "textBlock", {
  1410. /**
  1411. * Returns the image part of the button (if any)
  1412. */
  1413. get: function () {
  1414. return this._textBlock;
  1415. },
  1416. enumerable: true,
  1417. configurable: true
  1418. });
  1419. Button.prototype._getTypeName = function () {
  1420. return "Button";
  1421. };
  1422. // While being a container, the button behaves like a control.
  1423. /** @hidden */
  1424. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1425. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1426. return false;
  1427. }
  1428. if (!_super.prototype.contains.call(this, x, y)) {
  1429. return false;
  1430. }
  1431. this._processObservables(type, x, y, pointerId, buttonIndex);
  1432. return true;
  1433. };
  1434. /** @hidden */
  1435. Button.prototype._onPointerEnter = function (target) {
  1436. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1437. return false;
  1438. }
  1439. if (this.pointerEnterAnimation) {
  1440. this.pointerEnterAnimation();
  1441. }
  1442. return true;
  1443. };
  1444. /** @hidden */
  1445. Button.prototype._onPointerOut = function (target, force) {
  1446. if (force === void 0) { force = false; }
  1447. if (this.pointerOutAnimation) {
  1448. this.pointerOutAnimation();
  1449. }
  1450. _super.prototype._onPointerOut.call(this, target, force);
  1451. };
  1452. /** @hidden */
  1453. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1454. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1455. return false;
  1456. }
  1457. if (this.pointerDownAnimation) {
  1458. this.pointerDownAnimation();
  1459. }
  1460. return true;
  1461. };
  1462. /** @hidden */
  1463. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1464. if (this.pointerUpAnimation) {
  1465. this.pointerUpAnimation();
  1466. }
  1467. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1468. };
  1469. // Statics
  1470. /**
  1471. * Creates a new button made with an image and a text
  1472. * @param name defines the name of the button
  1473. * @param text defines the text of the button
  1474. * @param imageUrl defines the url of the image
  1475. * @returns a new Button
  1476. */
  1477. Button.CreateImageButton = function (name, text, imageUrl) {
  1478. var result = new Button(name);
  1479. // Adding text
  1480. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1481. textBlock.textWrapping = true;
  1482. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1483. textBlock.paddingLeft = "20%";
  1484. result.addControl(textBlock);
  1485. // Adding image
  1486. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1487. iconImage.width = "20%";
  1488. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1489. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1490. result.addControl(iconImage);
  1491. // Store
  1492. result._image = iconImage;
  1493. result._textBlock = textBlock;
  1494. return result;
  1495. };
  1496. /**
  1497. * Creates a new button made with an image
  1498. * @param name defines the name of the button
  1499. * @param imageUrl defines the url of the image
  1500. * @returns a new Button
  1501. */
  1502. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1503. var result = new Button(name);
  1504. // Adding image
  1505. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1506. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1507. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1508. result.addControl(iconImage);
  1509. // Store
  1510. result._image = iconImage;
  1511. return result;
  1512. };
  1513. /**
  1514. * Creates a new button made with a text
  1515. * @param name defines the name of the button
  1516. * @param text defines the text of the button
  1517. * @returns a new Button
  1518. */
  1519. Button.CreateSimpleButton = function (name, text) {
  1520. var result = new Button(name);
  1521. // Adding text
  1522. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1523. textBlock.textWrapping = true;
  1524. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1525. result.addControl(textBlock);
  1526. // Store
  1527. result._textBlock = textBlock;
  1528. return result;
  1529. };
  1530. /**
  1531. * Creates a new button made with an image and a centered text
  1532. * @param name defines the name of the button
  1533. * @param text defines the text of the button
  1534. * @param imageUrl defines the url of the image
  1535. * @returns a new Button
  1536. */
  1537. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1538. var result = new Button(name);
  1539. // Adding image
  1540. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1541. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1542. result.addControl(iconImage);
  1543. // Adding text
  1544. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1545. textBlock.textWrapping = true;
  1546. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1547. result.addControl(textBlock);
  1548. // Store
  1549. result._image = iconImage;
  1550. result._textBlock = textBlock;
  1551. return result;
  1552. };
  1553. return Button;
  1554. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1555. /***/ }),
  1556. /***/ "./2D/controls/checkbox.ts":
  1557. /*!*********************************!*\
  1558. !*** ./2D/controls/checkbox.ts ***!
  1559. \*********************************/
  1560. /*! exports provided: Checkbox */
  1561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1562. "use strict";
  1563. __webpack_require__.r(__webpack_exports__);
  1564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1565. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1566. <<<<<<< HEAD
  1567. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1568. =======
  1569. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  1570. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  1571. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1572. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1573. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1574. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1575. /**
  1576. * Class used to represent a 2D checkbox
  1577. */
  1578. var Checkbox = /** @class */ (function (_super) {
  1579. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1580. /**
  1581. * Creates a new CheckBox
  1582. * @param name defines the control name
  1583. */
  1584. function Checkbox(name) {
  1585. var _this = _super.call(this, name) || this;
  1586. _this.name = name;
  1587. _this._isChecked = false;
  1588. _this._background = "black";
  1589. _this._checkSizeRatio = 0.8;
  1590. _this._thickness = 1;
  1591. /**
  1592. * Observable raised when isChecked property changes
  1593. */
  1594. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1595. _this.isPointerBlocker = true;
  1596. return _this;
  1597. }
  1598. Object.defineProperty(Checkbox.prototype, "thickness", {
  1599. /** Gets or sets border thickness */
  1600. get: function () {
  1601. return this._thickness;
  1602. },
  1603. set: function (value) {
  1604. if (this._thickness === value) {
  1605. return;
  1606. }
  1607. this._thickness = value;
  1608. this._markAsDirty();
  1609. },
  1610. enumerable: true,
  1611. configurable: true
  1612. });
  1613. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1614. /** Gets or sets a value indicating the ratio between overall size and check size */
  1615. get: function () {
  1616. return this._checkSizeRatio;
  1617. },
  1618. set: function (value) {
  1619. value = Math.max(Math.min(1, value), 0);
  1620. if (this._checkSizeRatio === value) {
  1621. return;
  1622. }
  1623. this._checkSizeRatio = value;
  1624. this._markAsDirty();
  1625. },
  1626. enumerable: true,
  1627. configurable: true
  1628. });
  1629. Object.defineProperty(Checkbox.prototype, "background", {
  1630. /** Gets or sets background color */
  1631. get: function () {
  1632. return this._background;
  1633. },
  1634. set: function (value) {
  1635. if (this._background === value) {
  1636. return;
  1637. }
  1638. this._background = value;
  1639. this._markAsDirty();
  1640. },
  1641. enumerable: true,
  1642. configurable: true
  1643. });
  1644. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1645. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1646. get: function () {
  1647. return this._isChecked;
  1648. },
  1649. set: function (value) {
  1650. if (this._isChecked === value) {
  1651. return;
  1652. }
  1653. this._isChecked = value;
  1654. this._markAsDirty();
  1655. this.onIsCheckedChangedObservable.notifyObservers(value);
  1656. },
  1657. enumerable: true,
  1658. configurable: true
  1659. });
  1660. Checkbox.prototype._getTypeName = function () {
  1661. return "Checkbox";
  1662. };
  1663. /** @hidden */
  1664. Checkbox.prototype._draw = function (context) {
  1665. context.save();
  1666. this._applyStates(context);
  1667. var actualWidth = this._currentMeasure.width - this._thickness;
  1668. var actualHeight = this._currentMeasure.height - this._thickness;
  1669. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1670. context.shadowColor = this.shadowColor;
  1671. context.shadowBlur = this.shadowBlur;
  1672. context.shadowOffsetX = this.shadowOffsetX;
  1673. context.shadowOffsetY = this.shadowOffsetY;
  1674. }
  1675. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1676. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1677. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1678. context.shadowBlur = 0;
  1679. context.shadowOffsetX = 0;
  1680. context.shadowOffsetY = 0;
  1681. }
  1682. if (this._isChecked) {
  1683. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1684. var offsetWidth = actualWidth * this._checkSizeRatio;
  1685. var offseHeight = actualHeight * this._checkSizeRatio;
  1686. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1687. }
  1688. context.strokeStyle = this.color;
  1689. context.lineWidth = this._thickness;
  1690. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1691. context.restore();
  1692. };
  1693. // Events
  1694. /** @hidden */
  1695. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1696. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1697. return false;
  1698. }
  1699. this.isChecked = !this.isChecked;
  1700. return true;
  1701. };
  1702. /**
  1703. * Utility function to easily create a checkbox with a header
  1704. * @param title defines the label to use for the header
  1705. * @param onValueChanged defines the callback to call when value changes
  1706. * @returns a StackPanel containing the checkbox and a textBlock
  1707. */
  1708. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1709. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1710. panel.isVertical = false;
  1711. panel.height = "30px";
  1712. var checkbox = new Checkbox();
  1713. checkbox.width = "20px";
  1714. checkbox.height = "20px";
  1715. checkbox.isChecked = true;
  1716. checkbox.color = "green";
  1717. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1718. panel.addControl(checkbox);
  1719. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1720. header.text = title;
  1721. header.width = "180px";
  1722. header.paddingLeft = "5px";
  1723. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1724. header.color = "white";
  1725. panel.addControl(header);
  1726. return panel;
  1727. };
  1728. return Checkbox;
  1729. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1730. /***/ }),
  1731. /***/ "./2D/controls/colorpicker.ts":
  1732. /*!************************************!*\
  1733. !*** ./2D/controls/colorpicker.ts ***!
  1734. \************************************/
  1735. /*! exports provided: ColorPicker */
  1736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1737. "use strict";
  1738. __webpack_require__.r(__webpack_exports__);
  1739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1740. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1741. <<<<<<< HEAD
  1742. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1743. =======
  1744. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  1745. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  1746. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1747. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1748. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1749. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1750. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1751. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1752. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1753. /** Class used to create color pickers */
  1754. var ColorPicker = /** @class */ (function (_super) {
  1755. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1756. /**
  1757. * Creates a new ColorPicker
  1758. * @param name defines the control name
  1759. */
  1760. function ColorPicker(name) {
  1761. var _this = _super.call(this, name) || this;
  1762. _this.name = name;
  1763. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1764. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1765. _this._pointerStartedOnSquare = false;
  1766. _this._pointerStartedOnWheel = false;
  1767. _this._squareLeft = 0;
  1768. _this._squareTop = 0;
  1769. _this._squareSize = 0;
  1770. _this._h = 360;
  1771. _this._s = 1;
  1772. _this._v = 1;
  1773. _this._lastPointerDownID = -1;
  1774. /**
  1775. * Observable raised when the value changes
  1776. */
  1777. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1778. // Events
  1779. _this._pointerIsDown = false;
  1780. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1781. _this.size = "200px";
  1782. _this.isPointerBlocker = true;
  1783. return _this;
  1784. }
  1785. Object.defineProperty(ColorPicker.prototype, "value", {
  1786. /** Gets or sets the color of the color picker */
  1787. get: function () {
  1788. return this._value;
  1789. },
  1790. set: function (value) {
  1791. if (this._value.equals(value)) {
  1792. return;
  1793. }
  1794. this._value.copyFrom(value);
  1795. this._value.toHSVToRef(this._tmpColor);
  1796. this._h = this._tmpColor.r;
  1797. this._s = Math.max(this._tmpColor.g, 0.00001);
  1798. this._v = Math.max(this._tmpColor.b, 0.00001);
  1799. this._markAsDirty();
  1800. if (this._value.r <= ColorPicker._Epsilon) {
  1801. this._value.r = 0;
  1802. }
  1803. if (this._value.g <= ColorPicker._Epsilon) {
  1804. this._value.g = 0;
  1805. }
  1806. if (this._value.b <= ColorPicker._Epsilon) {
  1807. this._value.b = 0;
  1808. }
  1809. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1810. this._value.r = 1.0;
  1811. }
  1812. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1813. this._value.g = 1.0;
  1814. }
  1815. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1816. this._value.b = 1.0;
  1817. }
  1818. this.onValueChangedObservable.notifyObservers(this._value);
  1819. },
  1820. enumerable: true,
  1821. configurable: true
  1822. });
  1823. Object.defineProperty(ColorPicker.prototype, "width", {
  1824. /**
  1825. * Gets or sets control width
  1826. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1827. */
  1828. get: function () {
  1829. return this._width.toString(this._host);
  1830. },
  1831. set: function (value) {
  1832. if (this._width.toString(this._host) === value) {
  1833. return;
  1834. }
  1835. if (this._width.fromString(value)) {
  1836. this._height.fromString(value);
  1837. this._markAsDirty();
  1838. }
  1839. },
  1840. enumerable: true,
  1841. configurable: true
  1842. });
  1843. Object.defineProperty(ColorPicker.prototype, "height", {
  1844. /**
  1845. * Gets or sets control height
  1846. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1847. */
  1848. get: function () {
  1849. return this._height.toString(this._host);
  1850. },
  1851. /** Gets or sets control height */
  1852. set: function (value) {
  1853. if (this._height.toString(this._host) === value) {
  1854. return;
  1855. }
  1856. if (this._height.fromString(value)) {
  1857. this._width.fromString(value);
  1858. this._markAsDirty();
  1859. }
  1860. },
  1861. enumerable: true,
  1862. configurable: true
  1863. });
  1864. Object.defineProperty(ColorPicker.prototype, "size", {
  1865. /** Gets or sets control size */
  1866. get: function () {
  1867. return this.width;
  1868. },
  1869. set: function (value) {
  1870. this.width = value;
  1871. },
  1872. enumerable: true,
  1873. configurable: true
  1874. });
  1875. ColorPicker.prototype._getTypeName = function () {
  1876. return "ColorPicker";
  1877. };
  1878. /** @hidden */
  1879. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1880. if (parentMeasure.width < parentMeasure.height) {
  1881. this._currentMeasure.height = parentMeasure.width;
  1882. }
  1883. else {
  1884. this._currentMeasure.width = parentMeasure.height;
  1885. }
  1886. };
  1887. ColorPicker.prototype._updateSquareProps = function () {
  1888. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1889. var wheelThickness = radius * .2;
  1890. var innerDiameter = (radius - wheelThickness) * 2;
  1891. var squareSize = innerDiameter / (Math.sqrt(2));
  1892. var offset = radius - squareSize * .5;
  1893. this._squareLeft = this._currentMeasure.left + offset;
  1894. this._squareTop = this._currentMeasure.top + offset;
  1895. this._squareSize = squareSize;
  1896. };
  1897. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1898. var lgh = context.createLinearGradient(left, top, width + left, top);
  1899. lgh.addColorStop(0, '#fff');
  1900. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1901. context.fillStyle = lgh;
  1902. context.fillRect(left, top, width, height);
  1903. var lgv = context.createLinearGradient(left, top, left, height + top);
  1904. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1905. lgv.addColorStop(1, '#000');
  1906. context.fillStyle = lgv;
  1907. context.fillRect(left, top, width, height);
  1908. };
  1909. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1910. context.beginPath();
  1911. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1912. context.lineWidth = 3;
  1913. context.strokeStyle = '#333333';
  1914. context.stroke();
  1915. context.beginPath();
  1916. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1917. context.lineWidth = 3;
  1918. context.strokeStyle = '#ffffff';
  1919. context.stroke();
  1920. };
  1921. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1922. var canvas = document.createElement("canvas");
  1923. canvas.width = radius * 2;
  1924. canvas.height = radius * 2;
  1925. var context = canvas.getContext("2d");
  1926. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1927. var data = image.data;
  1928. var color = this._tmpColor;
  1929. var maxDistSq = radius * radius;
  1930. var innerRadius = radius - thickness;
  1931. var minDistSq = innerRadius * innerRadius;
  1932. for (var x = -radius; x < radius; x++) {
  1933. for (var y = -radius; y < radius; y++) {
  1934. var distSq = x * x + y * y;
  1935. if (distSq > maxDistSq || distSq < minDistSq) {
  1936. continue;
  1937. }
  1938. var dist = Math.sqrt(distSq);
  1939. var ang = Math.atan2(y, x);
  1940. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1941. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1942. data[index] = color.r * 255;
  1943. data[index + 1] = color.g * 255;
  1944. data[index + 2] = color.b * 255;
  1945. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1946. //apply less alpha to bigger color pickers
  1947. var alphaAmount = .2;
  1948. var maxAlpha = .2;
  1949. var minAlpha = .04;
  1950. var lowerRadius = 50;
  1951. var upperRadius = 150;
  1952. if (radius < lowerRadius) {
  1953. alphaAmount = maxAlpha;
  1954. }
  1955. else if (radius > upperRadius) {
  1956. alphaAmount = minAlpha;
  1957. }
  1958. else {
  1959. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1960. }
  1961. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1962. if (alphaRatio < alphaAmount) {
  1963. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1964. }
  1965. else if (alphaRatio > 1 - alphaAmount) {
  1966. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1967. }
  1968. else {
  1969. data[index + 3] = 255;
  1970. }
  1971. }
  1972. }
  1973. context.putImageData(image, 0, 0);
  1974. return canvas;
  1975. };
  1976. /** @hidden */
  1977. ColorPicker.prototype._draw = function (context) {
  1978. context.save();
  1979. this._applyStates(context);
  1980. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1981. var wheelThickness = radius * .2;
  1982. var left = this._currentMeasure.left;
  1983. var top = this._currentMeasure.top;
  1984. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  1985. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  1986. }
  1987. this._updateSquareProps();
  1988. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1989. context.shadowColor = this.shadowColor;
  1990. context.shadowBlur = this.shadowBlur;
  1991. context.shadowOffsetX = this.shadowOffsetX;
  1992. context.shadowOffsetY = this.shadowOffsetY;
  1993. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  1994. }
  1995. context.drawImage(this._colorWheelCanvas, left, top);
  1996. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1997. context.shadowBlur = 0;
  1998. context.shadowOffsetX = 0;
  1999. context.shadowOffsetY = 0;
  2000. }
  2001. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2002. var cx = this._squareLeft + this._squareSize * this._s;
  2003. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2004. this._drawCircle(cx, cy, radius * .04, context);
  2005. var dist = radius - wheelThickness * .5;
  2006. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2007. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2008. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2009. context.restore();
  2010. };
  2011. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2012. if (this._pointerStartedOnWheel) {
  2013. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2014. var centerX = radius + this._currentMeasure.left;
  2015. var centerY = radius + this._currentMeasure.top;
  2016. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2017. }
  2018. else if (this._pointerStartedOnSquare) {
  2019. this._updateSquareProps();
  2020. this._s = (x - this._squareLeft) / this._squareSize;
  2021. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2022. this._s = Math.min(this._s, 1);
  2023. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2024. this._v = Math.min(this._v, 1);
  2025. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2026. }
  2027. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2028. this.value = this._tmpColor;
  2029. };
  2030. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2031. this._updateSquareProps();
  2032. var left = this._squareLeft;
  2033. var top = this._squareTop;
  2034. var size = this._squareSize;
  2035. if (x >= left && x <= left + size &&
  2036. y >= top && y <= top + size) {
  2037. return true;
  2038. }
  2039. return false;
  2040. };
  2041. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2042. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2043. var centerX = radius + this._currentMeasure.left;
  2044. var centerY = radius + this._currentMeasure.top;
  2045. var wheelThickness = radius * .2;
  2046. var innerRadius = radius - wheelThickness;
  2047. var radiusSq = radius * radius;
  2048. var innerRadiusSq = innerRadius * innerRadius;
  2049. var dx = x - centerX;
  2050. var dy = y - centerY;
  2051. var distSq = dx * dx + dy * dy;
  2052. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2053. return true;
  2054. }
  2055. return false;
  2056. };
  2057. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2058. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2059. return false;
  2060. }
  2061. this._pointerIsDown = true;
  2062. this._pointerStartedOnSquare = false;
  2063. this._pointerStartedOnWheel = false;
  2064. // Invert transform
  2065. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2066. var x = this._transformedPosition.x;
  2067. var y = this._transformedPosition.y;
  2068. if (this._isPointOnSquare(x, y)) {
  2069. this._pointerStartedOnSquare = true;
  2070. }
  2071. else if (this._isPointOnWheel(x, y)) {
  2072. this._pointerStartedOnWheel = true;
  2073. }
  2074. this._updateValueFromPointer(x, y);
  2075. this._host._capturingControl[pointerId] = this;
  2076. this._lastPointerDownID = pointerId;
  2077. return true;
  2078. };
  2079. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2080. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2081. if (pointerId != this._lastPointerDownID) {
  2082. return;
  2083. }
  2084. // Invert transform
  2085. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2086. var x = this._transformedPosition.x;
  2087. var y = this._transformedPosition.y;
  2088. if (this._pointerIsDown) {
  2089. this._updateValueFromPointer(x, y);
  2090. }
  2091. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2092. };
  2093. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2094. this._pointerIsDown = false;
  2095. delete this._host._capturingControl[pointerId];
  2096. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2097. };
  2098. /**
  2099. * This function expands the color picker by creating a color picker dialog with manual
  2100. * color value input and the ability to save colors into an array to be used later in
  2101. * subsequent launches of the dialogue.
  2102. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2103. * @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.
  2104. * @returns picked color as a hex string and the saved colors array as hex strings.
  2105. */
  2106. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2107. return new Promise(function (resolve, reject) {
  2108. // Default options
  2109. options.pickerWidth = options.pickerWidth || "640px";
  2110. options.pickerHeight = options.pickerHeight || "400px";
  2111. options.headerHeight = options.headerHeight || "35px";
  2112. options.lastColor = options.lastColor || "#000000";
  2113. options.swatchLimit = options.swatchLimit || 20;
  2114. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2115. // Window size settings
  2116. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2117. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2118. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2119. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2120. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2121. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2122. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2123. // Button Colors
  2124. var buttonColor = "#c0c0c0";
  2125. var buttonBackgroundColor = "#535353";
  2126. var buttonBackgroundHoverColor = "#414141";
  2127. var buttonBackgroundClickColor = "515151";
  2128. var buttonDisabledColor = "#555555";
  2129. var buttonDisabledBackgroundColor = "#454545";
  2130. var currentSwatchesOutlineColor = "#404040";
  2131. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2132. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2133. var iconColorDark = "#aaaaaa";
  2134. var iconColorLight = "#ffffff";
  2135. var closeIconColor;
  2136. // Button settings
  2137. var buttonFontSize;
  2138. var butEdit;
  2139. var buttonWidth;
  2140. var buttonHeight;
  2141. // Input Text Colors
  2142. var inputFieldLabels = ["R", "G", "B"];
  2143. var inputTextBackgroundColor = "#454545";
  2144. var inputTextColor = "#f0f0f0";
  2145. // This is the current color as set by either the picker or by entering a value
  2146. var currentColor;
  2147. // This int is used for naming swatches and serves as the index for calling them from the list
  2148. var swatchNumber;
  2149. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2150. var swatchDrawer;
  2151. var editSwatchMode = false;
  2152. // Color InputText fields that will be updated upon value change
  2153. var picker;
  2154. var rValInt;
  2155. var gValInt;
  2156. var bValInt;
  2157. var rValDec;
  2158. var gValDec;
  2159. var bValDec;
  2160. var hexVal;
  2161. var newSwatch;
  2162. var lastVal;
  2163. var activeField;
  2164. /**
  2165. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2166. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2167. * are will receive no update. This is to prevent the input from the user being overwritten.
  2168. */
  2169. function updateValues(value, inputField) {
  2170. activeField = inputField;
  2171. var pickedColor = value.toHexString();
  2172. newSwatch.background = pickedColor;
  2173. if (rValInt.name != activeField) {
  2174. rValInt.text = Math.floor(value.r * 255).toString();
  2175. }
  2176. if (gValInt.name != activeField) {
  2177. gValInt.text = Math.floor(value.g * 255).toString();
  2178. }
  2179. if (bValInt.name != activeField) {
  2180. bValInt.text = Math.floor(value.b * 255).toString();
  2181. }
  2182. if (rValDec.name != activeField) {
  2183. rValDec.text = value.r.toString();
  2184. }
  2185. if (gValDec.name != activeField) {
  2186. gValDec.text = value.g.toString();
  2187. }
  2188. if (bValDec.name != activeField) {
  2189. bValDec.text = value.b.toString();
  2190. }
  2191. if (hexVal.name != activeField) {
  2192. var minusPound = pickedColor.split("#");
  2193. hexVal.text = minusPound[1];
  2194. }
  2195. if (picker.name != activeField) {
  2196. picker.value = value;
  2197. }
  2198. }
  2199. // 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.
  2200. function updateInt(field, channel) {
  2201. var newValue = field.text;
  2202. var checkVal = /[^0-9]/g.test(newValue);
  2203. if (checkVal) {
  2204. field.text = lastVal;
  2205. return;
  2206. }
  2207. else {
  2208. if (newValue != "") {
  2209. if (Math.floor(parseInt(newValue)) < 0) {
  2210. newValue = "0";
  2211. }
  2212. else if (Math.floor(parseInt(newValue)) > 255) {
  2213. newValue = "255";
  2214. }
  2215. else if (isNaN(parseInt(newValue))) {
  2216. newValue = "0";
  2217. }
  2218. }
  2219. if (activeField == field.name) {
  2220. lastVal = newValue;
  2221. }
  2222. }
  2223. if (newValue != "") {
  2224. newValue = parseInt(newValue).toString();
  2225. field.text = newValue;
  2226. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2227. if (activeField == field.name) {
  2228. if (channel == "r") {
  2229. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2230. }
  2231. else if (channel == "g") {
  2232. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2233. }
  2234. else {
  2235. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2236. }
  2237. }
  2238. }
  2239. }
  2240. // 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.
  2241. function updateFloat(field, channel) {
  2242. var newValue = field.text;
  2243. var checkVal = /[^0-9\.]/g.test(newValue);
  2244. if (checkVal) {
  2245. field.text = lastVal;
  2246. return;
  2247. }
  2248. else {
  2249. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2250. if (parseFloat(newValue) < 0.0) {
  2251. newValue = "0.0";
  2252. }
  2253. else if (parseFloat(newValue) > 1.0) {
  2254. newValue = "1.0";
  2255. }
  2256. else if (isNaN(parseFloat(newValue))) {
  2257. newValue = "0.0";
  2258. }
  2259. }
  2260. if (activeField == field.name) {
  2261. lastVal = newValue;
  2262. }
  2263. }
  2264. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2265. newValue = parseFloat(newValue).toString();
  2266. field.text = newValue;
  2267. }
  2268. else {
  2269. newValue = "0.0";
  2270. }
  2271. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2272. if (activeField == field.name) {
  2273. if (channel == "r") {
  2274. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2275. }
  2276. else if (channel == "g") {
  2277. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2278. }
  2279. else {
  2280. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2281. }
  2282. }
  2283. }
  2284. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2285. function deleteSwatch(index) {
  2286. if (options.savedColors) {
  2287. options.savedColors.splice(index, 1);
  2288. }
  2289. if (options.savedColors && options.savedColors.length == 0) {
  2290. setEditButtonVisibility(false);
  2291. editSwatchMode = false;
  2292. }
  2293. }
  2294. // Creates and styles an individual swatch when updateSwatches is called.
  2295. function createSwatch() {
  2296. if (options.savedColors && options.savedColors[swatchNumber]) {
  2297. if (editSwatchMode) {
  2298. var icon = "b";
  2299. }
  2300. else {
  2301. var icon = "";
  2302. }
  2303. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2304. swatch.fontFamily = "BabylonJSglyphs";
  2305. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2306. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2307. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2308. if (swatchLuminence > luminanceLimit) {
  2309. swatch.color = iconColorDark;
  2310. }
  2311. else {
  2312. swatch.color = iconColorLight;
  2313. }
  2314. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2315. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2316. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2317. swatch.background = options.savedColors[swatchNumber];
  2318. swatch.thickness = 2;
  2319. var metadata_1 = swatchNumber;
  2320. swatch.pointerDownAnimation = function () {
  2321. swatch.thickness = 4;
  2322. };
  2323. swatch.pointerUpAnimation = function () {
  2324. swatch.thickness = 3;
  2325. };
  2326. swatch.pointerEnterAnimation = function () {
  2327. swatch.thickness = 3;
  2328. };
  2329. swatch.pointerOutAnimation = function () {
  2330. swatch.thickness = 2;
  2331. };
  2332. swatch.onPointerClickObservable.add(function () {
  2333. if (!editSwatchMode) {
  2334. if (options.savedColors) {
  2335. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2336. }
  2337. }
  2338. else {
  2339. deleteSwatch(metadata_1);
  2340. updateSwatches("", butSave);
  2341. }
  2342. });
  2343. return swatch;
  2344. }
  2345. else {
  2346. return null;
  2347. }
  2348. }
  2349. // Mode switch to render button text and close symbols on swatch controls
  2350. function editSwatches(mode) {
  2351. if (mode !== undefined) {
  2352. editSwatchMode = mode;
  2353. }
  2354. if (editSwatchMode) {
  2355. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2356. var thisButton = swatchDrawer.children[i];
  2357. thisButton.textBlock.text = "b";
  2358. }
  2359. if (butEdit !== undefined) {
  2360. butEdit.textBlock.text = "Done";
  2361. }
  2362. }
  2363. else {
  2364. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2365. var thisButton = swatchDrawer.children[i];
  2366. thisButton.textBlock.text = "";
  2367. }
  2368. if (butEdit !== undefined) {
  2369. butEdit.textBlock.text = "Edit";
  2370. }
  2371. }
  2372. }
  2373. /**
  2374. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2375. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2376. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2377. * saved colors there are and how many can be stored per row.
  2378. */
  2379. function updateSwatches(color, button) {
  2380. if (options.savedColors) {
  2381. if (color != "") {
  2382. options.savedColors.push(color);
  2383. }
  2384. swatchNumber = 0;
  2385. swatchDrawer.clearControls();
  2386. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2387. if (rowCount == 0) {
  2388. var gutterCount = 0;
  2389. }
  2390. else {
  2391. var gutterCount = rowCount + 1;
  2392. }
  2393. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2394. var currentRows = swatchDrawer.rowCount;
  2395. for (var i = 0; i < currentRows; i++) {
  2396. swatchDrawer.removeRowDefinition(0);
  2397. }
  2398. for (var i = 0; i < rowCount + gutterCount; i++) {
  2399. if (i % 2) {
  2400. swatchDrawer.addRowDefinition(swatchSize, true);
  2401. }
  2402. else {
  2403. swatchDrawer.addRowDefinition(gutterSize, true);
  2404. }
  2405. }
  2406. }
  2407. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2408. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2409. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2410. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2411. var totalButtonsThisRow = options.numSwatchesPerLine;
  2412. }
  2413. else {
  2414. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2415. }
  2416. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2417. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2418. if (x > options.numSwatchesPerLine) {
  2419. continue;
  2420. }
  2421. var swatch = createSwatch();
  2422. if (swatch != null) {
  2423. swatchDrawer.addControl(swatch, y, w);
  2424. w += 2;
  2425. swatchNumber++;
  2426. }
  2427. else {
  2428. continue;
  2429. }
  2430. }
  2431. }
  2432. if (options.savedColors.length >= options.swatchLimit) {
  2433. disableButton(button, true);
  2434. }
  2435. else {
  2436. disableButton(button, false);
  2437. }
  2438. }
  2439. }
  2440. // Shows or hides edit swatches button depending on if there are saved swatches
  2441. function setEditButtonVisibility(enableButton) {
  2442. if (enableButton) {
  2443. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2444. butEdit.width = buttonWidth;
  2445. butEdit.height = buttonHeight;
  2446. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2447. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2448. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2449. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2450. butEdit.thickness = 2;
  2451. butEdit.color = buttonColor;
  2452. butEdit.fontSize = buttonFontSize;
  2453. butEdit.background = buttonBackgroundColor;
  2454. butEdit.onPointerEnterObservable.add(function () {
  2455. butEdit.background = buttonBackgroundHoverColor;
  2456. });
  2457. butEdit.onPointerOutObservable.add(function () {
  2458. butEdit.background = buttonBackgroundColor;
  2459. });
  2460. butEdit.pointerDownAnimation = function () {
  2461. butEdit.background = buttonBackgroundClickColor;
  2462. };
  2463. butEdit.pointerUpAnimation = function () {
  2464. butEdit.background = buttonBackgroundHoverColor;
  2465. };
  2466. butEdit.onPointerClickObservable.add(function () {
  2467. if (editSwatchMode) {
  2468. editSwatchMode = false;
  2469. }
  2470. else {
  2471. editSwatchMode = true;
  2472. }
  2473. editSwatches();
  2474. });
  2475. pickerGrid.addControl(butEdit, 1, 0);
  2476. }
  2477. else {
  2478. pickerGrid.removeControl(butEdit);
  2479. }
  2480. }
  2481. // Called when the user hits the limit of saved colors in the drawer.
  2482. function disableButton(button, disabled) {
  2483. if (disabled) {
  2484. button.color = buttonDisabledColor;
  2485. button.background = buttonDisabledBackgroundColor;
  2486. }
  2487. else {
  2488. button.color = buttonColor;
  2489. button.background = buttonBackgroundColor;
  2490. }
  2491. }
  2492. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2493. function closePicker(color) {
  2494. if (options.savedColors && options.savedColors.length > 0) {
  2495. resolve({
  2496. savedColors: options.savedColors,
  2497. pickedColor: color
  2498. });
  2499. }
  2500. else {
  2501. resolve({
  2502. pickedColor: color
  2503. });
  2504. }
  2505. advancedTexture.removeControl(dialogContainer);
  2506. }
  2507. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2508. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2509. dialogContainer.name = "Dialog Container";
  2510. dialogContainer.width = options.pickerWidth;
  2511. if (options.savedColors) {
  2512. dialogContainer.height = containerSize;
  2513. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2514. dialogContainer.addRowDefinition(topRow, false);
  2515. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2516. }
  2517. else {
  2518. dialogContainer.height = options.pickerHeight;
  2519. dialogContainer.addRowDefinition(1.0, false);
  2520. }
  2521. advancedTexture.addControl(dialogContainer);
  2522. // Swatch drawer which contains all saved color buttons
  2523. if (options.savedColors) {
  2524. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2525. swatchDrawer.name = "Swatch Drawer";
  2526. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2527. swatchDrawer.background = buttonBackgroundColor;
  2528. swatchDrawer.width = options.pickerWidth;
  2529. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2530. if (initialRows == 0) {
  2531. var gutterCount = 0;
  2532. }
  2533. else {
  2534. var gutterCount = initialRows + 1;
  2535. }
  2536. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2537. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2538. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2539. if (i % 2 != 0) {
  2540. swatchDrawer.addRowDefinition(swatchSize, true);
  2541. }
  2542. else {
  2543. swatchDrawer.addRowDefinition(gutterSize, true);
  2544. }
  2545. }
  2546. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2547. if (i % 2 != 0) {
  2548. swatchDrawer.addColumnDefinition(swatchSize, true);
  2549. }
  2550. else {
  2551. swatchDrawer.addColumnDefinition(gutterSize, true);
  2552. }
  2553. }
  2554. dialogContainer.addControl(swatchDrawer, 1, 0);
  2555. }
  2556. // Picker container
  2557. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2558. pickerPanel.name = "Picker Panel";
  2559. pickerPanel.height = options.pickerHeight;
  2560. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2561. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2562. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2563. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2564. dialogContainer.addControl(pickerPanel, 0, 0);
  2565. // Picker container header
  2566. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2567. header.name = "Dialogue Header Bar";
  2568. header.background = "#cccccc";
  2569. header.thickness = 0;
  2570. pickerPanel.addControl(header, 0, 0);
  2571. // Header close button
  2572. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2573. closeButton.fontFamily = "BabylonJSglyphs";
  2574. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2575. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2576. closeButton.color = closeIconColor.toHexString();
  2577. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2578. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2579. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2580. closeButton.height = closeButton.width = options.headerHeight;
  2581. closeButton.background = header.background;
  2582. closeButton.thickness = 0;
  2583. closeButton.pointerDownAnimation = function () {
  2584. };
  2585. closeButton.pointerUpAnimation = function () {
  2586. closeButton.background = header.background;
  2587. };
  2588. closeButton.pointerEnterAnimation = function () {
  2589. closeButton.color = header.background;
  2590. closeButton.background = "red";
  2591. };
  2592. closeButton.pointerOutAnimation = function () {
  2593. closeButton.color = closeIconColor.toHexString();
  2594. closeButton.background = header.background;
  2595. };
  2596. closeButton.onPointerClickObservable.add(function () {
  2597. closePicker(currentSwatch.background);
  2598. });
  2599. pickerPanel.addControl(closeButton, 0, 0);
  2600. // Dialog container body
  2601. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2602. dialogBody.name = "Dialogue Body";
  2603. dialogBody.background = buttonBackgroundColor;
  2604. var dialogBodyCols = [0.4375, 0.5625];
  2605. dialogBody.addRowDefinition(1.0, false);
  2606. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2607. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2608. pickerPanel.addControl(dialogBody, 1, 0);
  2609. // Picker grid
  2610. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2611. pickerGrid.name = "Picker Grid";
  2612. pickerGrid.addRowDefinition(0.85, false);
  2613. pickerGrid.addRowDefinition(0.15, false);
  2614. dialogBody.addControl(pickerGrid, 0, 0);
  2615. // Picker control
  2616. picker = new ColorPicker();
  2617. picker.name = "GUI Color Picker";
  2618. if (options.pickerHeight < options.pickerWidth) {
  2619. picker.width = 0.89;
  2620. }
  2621. else {
  2622. picker.height = 0.89;
  2623. }
  2624. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2625. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2626. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2627. picker.onPointerDownObservable.add(function () {
  2628. activeField = picker.name;
  2629. lastVal = "";
  2630. editSwatches(false);
  2631. });
  2632. picker.onValueChangedObservable.add(function (value) {
  2633. if (activeField == picker.name) {
  2634. updateValues(value, picker.name);
  2635. }
  2636. });
  2637. pickerGrid.addControl(picker, 0, 0);
  2638. // Picker body right quarant
  2639. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2640. pickerBodyRight.name = "Dialogue Right Half";
  2641. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2642. var pickerBodyRightRows = [0.514, 0.486];
  2643. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2644. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2645. dialogBody.addControl(pickerBodyRight, 1, 1);
  2646. // Picker container swatches and buttons
  2647. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2648. pickerSwatchesButtons.name = "Swatches and Buttons";
  2649. var pickerButtonsCol = [0.417, 0.583];
  2650. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2651. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2652. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2653. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2654. // Picker Swatches quadrant
  2655. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2656. pickerSwatches.name = "New and Current Swatches";
  2657. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2658. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2659. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2660. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2661. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2662. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2663. // Active swatches
  2664. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2665. activeSwatches.name = "Active Swatches";
  2666. activeSwatches.width = 0.67;
  2667. activeSwatches.addRowDefinition(0.5, false);
  2668. activeSwatches.addRowDefinition(0.5, false);
  2669. pickerSwatches.addControl(activeSwatches, 2, 0);
  2670. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2671. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2672. if (options.pickerWidth > options.pickerHeight) {
  2673. var labelTextSize = labelHeight;
  2674. }
  2675. else {
  2676. var labelTextSize = labelWidth;
  2677. }
  2678. // New color swatch and previous color button
  2679. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2680. newText.text = "new";
  2681. newText.name = "New Color Label";
  2682. newText.color = buttonColor;
  2683. newText.fontSize = labelTextSize;
  2684. pickerSwatches.addControl(newText, 1, 0);
  2685. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2686. newSwatch.name = "New Color Swatch";
  2687. newSwatch.background = options.lastColor;
  2688. newSwatch.thickness = 0;
  2689. activeSwatches.addControl(newSwatch, 0, 0);
  2690. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2691. currentSwatch.background = options.lastColor;
  2692. currentSwatch.thickness = 0;
  2693. currentSwatch.onPointerClickObservable.add(function () {
  2694. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2695. updateValues(revertColor, currentSwatch.name);
  2696. editSwatches(false);
  2697. });
  2698. currentSwatch.pointerDownAnimation = function () { };
  2699. currentSwatch.pointerUpAnimation = function () { };
  2700. currentSwatch.pointerEnterAnimation = function () { };
  2701. currentSwatch.pointerOutAnimation = function () { };
  2702. activeSwatches.addControl(currentSwatch, 1, 0);
  2703. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2704. swatchOutline.name = "Swatch Outline";
  2705. swatchOutline.width = 0.67;
  2706. swatchOutline.thickness = 2;
  2707. swatchOutline.color = currentSwatchesOutlineColor;
  2708. swatchOutline.isHitTestVisible = false;
  2709. pickerSwatches.addControl(swatchOutline, 2, 0);
  2710. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2711. currentText.name = "Current Color Label";
  2712. currentText.text = "current";
  2713. currentText.color = buttonColor;
  2714. currentText.fontSize = labelTextSize;
  2715. pickerSwatches.addControl(currentText, 3, 0);
  2716. // Buttons grid
  2717. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2718. buttonGrid.name = "Button Grid";
  2719. buttonGrid.height = 0.8;
  2720. var buttonGridRows = 1 / 3;
  2721. buttonGrid.addRowDefinition(buttonGridRows, false);
  2722. buttonGrid.addRowDefinition(buttonGridRows, false);
  2723. buttonGrid.addRowDefinition(buttonGridRows, false);
  2724. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2725. // Determine pixel width and height for all buttons from overall panel dimensions
  2726. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2727. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2728. // Determine button type size
  2729. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2730. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2731. }
  2732. else {
  2733. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2734. }
  2735. // Panel Buttons
  2736. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2737. butOK.width = buttonWidth;
  2738. butOK.height = buttonHeight;
  2739. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2740. butOK.thickness = 2;
  2741. butOK.color = buttonColor;
  2742. butOK.fontSize = buttonFontSize;
  2743. butOK.background = buttonBackgroundColor;
  2744. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2745. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2746. butOK.pointerDownAnimation = function () {
  2747. butOK.background = buttonBackgroundClickColor;
  2748. };
  2749. butOK.pointerUpAnimation = function () {
  2750. butOK.background = buttonBackgroundHoverColor;
  2751. };
  2752. butOK.onPointerClickObservable.add(function () {
  2753. editSwatches(false);
  2754. closePicker(newSwatch.background);
  2755. });
  2756. buttonGrid.addControl(butOK, 0, 0);
  2757. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2758. butCancel.width = buttonWidth;
  2759. butCancel.height = buttonHeight;
  2760. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2761. butCancel.thickness = 2;
  2762. butCancel.color = buttonColor;
  2763. butCancel.fontSize = buttonFontSize;
  2764. butCancel.background = buttonBackgroundColor;
  2765. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2766. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2767. butCancel.pointerDownAnimation = function () {
  2768. butCancel.background = buttonBackgroundClickColor;
  2769. };
  2770. butCancel.pointerUpAnimation = function () {
  2771. butCancel.background = buttonBackgroundHoverColor;
  2772. };
  2773. butCancel.onPointerClickObservable.add(function () {
  2774. editSwatches(false);
  2775. closePicker(currentSwatch.background);
  2776. });
  2777. buttonGrid.addControl(butCancel, 1, 0);
  2778. if (options.savedColors) {
  2779. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2780. butSave.width = buttonWidth;
  2781. butSave.height = buttonHeight;
  2782. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2783. butSave.thickness = 2;
  2784. butSave.fontSize = buttonFontSize;
  2785. if (options.savedColors.length < options.swatchLimit) {
  2786. butSave.color = buttonColor;
  2787. butSave.background = buttonBackgroundColor;
  2788. }
  2789. else {
  2790. disableButton(butSave, true);
  2791. }
  2792. butSave.onPointerEnterObservable.add(function () {
  2793. if (options.savedColors) {
  2794. if (options.savedColors.length < options.swatchLimit) {
  2795. butSave.background = buttonBackgroundHoverColor;
  2796. }
  2797. }
  2798. });
  2799. butSave.onPointerOutObservable.add(function () {
  2800. if (options.savedColors) {
  2801. if (options.savedColors.length < options.swatchLimit) {
  2802. butSave.background = buttonBackgroundColor;
  2803. }
  2804. }
  2805. });
  2806. butSave.pointerDownAnimation = function () {
  2807. if (options.savedColors) {
  2808. if (options.savedColors.length < options.swatchLimit) {
  2809. butSave.background = buttonBackgroundClickColor;
  2810. }
  2811. }
  2812. };
  2813. butSave.pointerUpAnimation = function () {
  2814. if (options.savedColors) {
  2815. if (options.savedColors.length < options.swatchLimit) {
  2816. butSave.background = buttonBackgroundHoverColor;
  2817. }
  2818. }
  2819. };
  2820. butSave.onPointerClickObservable.add(function () {
  2821. if (options.savedColors) {
  2822. if (options.savedColors.length == 0) {
  2823. setEditButtonVisibility(true);
  2824. }
  2825. if (options.savedColors.length < options.swatchLimit) {
  2826. updateSwatches(newSwatch.background, butSave);
  2827. }
  2828. editSwatches(false);
  2829. }
  2830. });
  2831. if (options.savedColors.length > 0) {
  2832. setEditButtonVisibility(true);
  2833. }
  2834. buttonGrid.addControl(butSave, 2, 0);
  2835. }
  2836. // Picker color values input
  2837. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2838. pickerColorValues.name = "Dialog Lower Right";
  2839. pickerColorValues.addRowDefinition(0.02, false);
  2840. pickerColorValues.addRowDefinition(0.63, false);
  2841. pickerColorValues.addRowDefinition(0.21, false);
  2842. pickerColorValues.addRowDefinition(0.14, false);
  2843. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2844. // RGB values text boxes
  2845. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2846. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2847. rgbValuesQuadrant.name = "RGB Values";
  2848. rgbValuesQuadrant.width = 0.82;
  2849. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2850. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2851. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2852. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2853. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2854. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2855. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2856. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2857. for (var i = 0; i < inputFieldLabels.length; i++) {
  2858. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2859. labelText.text = inputFieldLabels[i];
  2860. labelText.color = buttonColor;
  2861. labelText.fontSize = buttonFontSize;
  2862. rgbValuesQuadrant.addControl(labelText, i, 0);
  2863. }
  2864. // Input fields for RGB values
  2865. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2866. rValInt.width = 0.83;
  2867. rValInt.height = 0.72;
  2868. rValInt.name = "rIntField";
  2869. rValInt.fontSize = buttonFontSize;
  2870. rValInt.text = (currentColor.r * 255).toString();
  2871. rValInt.color = inputTextColor;
  2872. rValInt.background = inputTextBackgroundColor;
  2873. rValInt.onFocusObservable.add(function () {
  2874. activeField = rValInt.name;
  2875. lastVal = rValInt.text;
  2876. editSwatches(false);
  2877. });
  2878. rValInt.onBlurObservable.add(function () {
  2879. if (rValInt.text == "") {
  2880. rValInt.text = "0";
  2881. }
  2882. updateInt(rValInt, "r");
  2883. if (activeField == rValInt.name) {
  2884. activeField = "";
  2885. }
  2886. });
  2887. rValInt.onTextChangedObservable.add(function () {
  2888. if (activeField == rValInt.name) {
  2889. updateInt(rValInt, "r");
  2890. }
  2891. });
  2892. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2893. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2894. gValInt.width = 0.83;
  2895. gValInt.height = 0.72;
  2896. gValInt.name = "gIntField";
  2897. gValInt.fontSize = buttonFontSize;
  2898. gValInt.text = (currentColor.g * 255).toString();
  2899. gValInt.color = inputTextColor;
  2900. gValInt.background = inputTextBackgroundColor;
  2901. gValInt.onFocusObservable.add(function () {
  2902. activeField = gValInt.name;
  2903. lastVal = gValInt.text;
  2904. editSwatches(false);
  2905. });
  2906. gValInt.onBlurObservable.add(function () {
  2907. if (gValInt.text == "") {
  2908. gValInt.text = "0";
  2909. }
  2910. updateInt(gValInt, "g");
  2911. if (activeField == gValInt.name) {
  2912. activeField = "";
  2913. }
  2914. });
  2915. gValInt.onTextChangedObservable.add(function () {
  2916. if (activeField == gValInt.name) {
  2917. updateInt(gValInt, "g");
  2918. }
  2919. });
  2920. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2921. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2922. bValInt.width = 0.83;
  2923. bValInt.height = 0.72;
  2924. bValInt.name = "bIntField";
  2925. bValInt.fontSize = buttonFontSize;
  2926. bValInt.text = (currentColor.b * 255).toString();
  2927. bValInt.color = inputTextColor;
  2928. bValInt.background = inputTextBackgroundColor;
  2929. bValInt.onFocusObservable.add(function () {
  2930. activeField = bValInt.name;
  2931. lastVal = bValInt.text;
  2932. editSwatches(false);
  2933. });
  2934. bValInt.onBlurObservable.add(function () {
  2935. if (bValInt.text == "") {
  2936. bValInt.text = "0";
  2937. }
  2938. updateInt(bValInt, "b");
  2939. if (activeField == bValInt.name) {
  2940. activeField = "";
  2941. }
  2942. });
  2943. bValInt.onTextChangedObservable.add(function () {
  2944. if (activeField == bValInt.name) {
  2945. updateInt(bValInt, "b");
  2946. }
  2947. });
  2948. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2949. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2950. rValDec.width = 0.95;
  2951. rValDec.height = 0.72;
  2952. rValDec.name = "rDecField";
  2953. rValDec.fontSize = buttonFontSize;
  2954. rValDec.text = currentColor.r.toString();
  2955. rValDec.color = inputTextColor;
  2956. rValDec.background = inputTextBackgroundColor;
  2957. rValDec.onFocusObservable.add(function () {
  2958. activeField = rValDec.name;
  2959. lastVal = rValDec.text;
  2960. editSwatches(false);
  2961. });
  2962. rValDec.onBlurObservable.add(function () {
  2963. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2964. rValDec.text = "0";
  2965. updateFloat(rValDec, "r");
  2966. }
  2967. if (activeField == rValDec.name) {
  2968. activeField = "";
  2969. }
  2970. });
  2971. rValDec.onTextChangedObservable.add(function () {
  2972. if (activeField == rValDec.name) {
  2973. updateFloat(rValDec, "r");
  2974. }
  2975. });
  2976. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  2977. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2978. gValDec.width = 0.95;
  2979. gValDec.height = 0.72;
  2980. gValDec.name = "gDecField";
  2981. gValDec.fontSize = buttonFontSize;
  2982. gValDec.text = currentColor.g.toString();
  2983. gValDec.color = inputTextColor;
  2984. gValDec.background = inputTextBackgroundColor;
  2985. gValDec.onFocusObservable.add(function () {
  2986. activeField = gValDec.name;
  2987. lastVal = gValDec.text;
  2988. editSwatches(false);
  2989. });
  2990. gValDec.onBlurObservable.add(function () {
  2991. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  2992. gValDec.text = "0";
  2993. updateFloat(gValDec, "g");
  2994. }
  2995. if (activeField == gValDec.name) {
  2996. activeField = "";
  2997. }
  2998. });
  2999. gValDec.onTextChangedObservable.add(function () {
  3000. if (activeField == gValDec.name) {
  3001. updateFloat(gValDec, "g");
  3002. }
  3003. });
  3004. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3005. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3006. bValDec.width = 0.95;
  3007. bValDec.height = 0.72;
  3008. bValDec.name = "bDecField";
  3009. bValDec.fontSize = buttonFontSize;
  3010. bValDec.text = currentColor.b.toString();
  3011. bValDec.color = inputTextColor;
  3012. bValDec.background = inputTextBackgroundColor;
  3013. bValDec.onFocusObservable.add(function () {
  3014. activeField = bValDec.name;
  3015. lastVal = bValDec.text;
  3016. editSwatches(false);
  3017. });
  3018. bValDec.onBlurObservable.add(function () {
  3019. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3020. bValDec.text = "0";
  3021. updateFloat(bValDec, "b");
  3022. }
  3023. if (activeField == bValDec.name) {
  3024. activeField = "";
  3025. }
  3026. });
  3027. bValDec.onTextChangedObservable.add(function () {
  3028. if (activeField == bValDec.name) {
  3029. updateFloat(bValDec, "b");
  3030. }
  3031. });
  3032. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3033. // Hex value input
  3034. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3035. hexValueQuadrant.name = "Hex Value";
  3036. hexValueQuadrant.width = 0.82;
  3037. hexValueQuadrant.addRowDefinition(1.0, false);
  3038. hexValueQuadrant.addColumnDefinition(0.1, false);
  3039. hexValueQuadrant.addColumnDefinition(0.9, false);
  3040. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3041. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3042. labelText.text = "#";
  3043. labelText.color = buttonColor;
  3044. labelText.fontSize = buttonFontSize;
  3045. hexValueQuadrant.addControl(labelText, 0, 0);
  3046. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3047. hexVal.width = 0.96;
  3048. hexVal.height = 0.72;
  3049. hexVal.name = "hexField";
  3050. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3051. hexVal.fontSize = buttonFontSize;
  3052. var minusPound = options.lastColor.split("#");
  3053. hexVal.text = minusPound[1];
  3054. hexVal.color = inputTextColor;
  3055. hexVal.background = inputTextBackgroundColor;
  3056. hexVal.onFocusObservable.add(function () {
  3057. activeField = hexVal.name;
  3058. lastVal = hexVal.text;
  3059. editSwatches(false);
  3060. });
  3061. hexVal.onBlurObservable.add(function () {
  3062. if (hexVal.text.length == 3) {
  3063. var val = hexVal.text.split("");
  3064. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3065. }
  3066. if (hexVal.text == "") {
  3067. hexVal.text = "000000";
  3068. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3069. }
  3070. if (activeField == hexVal.name) {
  3071. activeField = "";
  3072. }
  3073. });
  3074. hexVal.onTextChangedObservable.add(function () {
  3075. var newHexValue = hexVal.text;
  3076. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3077. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3078. hexVal.text = lastVal;
  3079. }
  3080. else {
  3081. if (hexVal.text.length < 6) {
  3082. var leadingZero = 6 - hexVal.text.length;
  3083. for (var i = 0; i < leadingZero; i++) {
  3084. newHexValue = "0" + newHexValue;
  3085. }
  3086. }
  3087. if (hexVal.text.length == 3) {
  3088. var val = hexVal.text.split("");
  3089. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3090. }
  3091. newHexValue = "#" + newHexValue;
  3092. if (activeField == hexVal.name) {
  3093. lastVal = hexVal.text;
  3094. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3095. }
  3096. }
  3097. });
  3098. hexValueQuadrant.addControl(hexVal, 0, 1);
  3099. if (options.savedColors && options.savedColors.length > 0) {
  3100. updateSwatches("", butSave);
  3101. }
  3102. });
  3103. };
  3104. ColorPicker._Epsilon = 0.000001;
  3105. return ColorPicker;
  3106. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3107. /***/ }),
  3108. /***/ "./2D/controls/container.ts":
  3109. /*!**********************************!*\
  3110. !*** ./2D/controls/container.ts ***!
  3111. \**********************************/
  3112. /*! exports provided: Container */
  3113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3114. "use strict";
  3115. __webpack_require__.r(__webpack_exports__);
  3116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3117. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3118. <<<<<<< HEAD
  3119. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable");
  3120. =======
  3121. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/tools");
  3122. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  3123. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3124. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3125. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3126. /**
  3127. * Root class for 2D containers
  3128. * @see http://doc.babylonjs.com/how_to/gui#containers
  3129. */
  3130. var Container = /** @class */ (function (_super) {
  3131. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3132. /**
  3133. * Creates a new Container
  3134. * @param name defines the name of the container
  3135. */
  3136. function Container(name) {
  3137. var _this = _super.call(this, name) || this;
  3138. _this.name = name;
  3139. /** @hidden */
  3140. _this._children = new Array();
  3141. /** @hidden */
  3142. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3143. /** @hidden */
  3144. _this._background = "";
  3145. /** @hidden */
  3146. _this._adaptWidthToChildren = false;
  3147. /** @hidden */
  3148. _this._adaptHeightToChildren = false;
  3149. return _this;
  3150. }
  3151. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3152. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3153. get: function () {
  3154. return this._adaptHeightToChildren;
  3155. },
  3156. set: function (value) {
  3157. if (this._adaptHeightToChildren === value) {
  3158. return;
  3159. }
  3160. this._adaptHeightToChildren = value;
  3161. if (value) {
  3162. this.height = "100%";
  3163. }
  3164. this._markAsDirty();
  3165. },
  3166. enumerable: true,
  3167. configurable: true
  3168. });
  3169. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3170. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3171. get: function () {
  3172. return this._adaptWidthToChildren;
  3173. },
  3174. set: function (value) {
  3175. if (this._adaptWidthToChildren === value) {
  3176. return;
  3177. }
  3178. this._adaptWidthToChildren = value;
  3179. if (value) {
  3180. this.width = "100%";
  3181. }
  3182. this._markAsDirty();
  3183. },
  3184. enumerable: true,
  3185. configurable: true
  3186. });
  3187. Object.defineProperty(Container.prototype, "background", {
  3188. /** Gets or sets background color */
  3189. get: function () {
  3190. return this._background;
  3191. },
  3192. set: function (value) {
  3193. if (this._background === value) {
  3194. return;
  3195. }
  3196. this._background = value;
  3197. this._markAsDirty();
  3198. },
  3199. enumerable: true,
  3200. configurable: true
  3201. });
  3202. Object.defineProperty(Container.prototype, "children", {
  3203. /** Gets the list of children */
  3204. get: function () {
  3205. return this._children;
  3206. },
  3207. enumerable: true,
  3208. configurable: true
  3209. });
  3210. Container.prototype._getTypeName = function () {
  3211. return "Container";
  3212. };
  3213. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3214. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3215. var child = _a[_i];
  3216. child._markMatrixAsDirty();
  3217. }
  3218. };
  3219. /**
  3220. * Gets a child using its name
  3221. * @param name defines the child name to look for
  3222. * @returns the child control if found
  3223. */
  3224. Container.prototype.getChildByName = function (name) {
  3225. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3226. var child = _a[_i];
  3227. if (child.name === name) {
  3228. return child;
  3229. }
  3230. }
  3231. return null;
  3232. };
  3233. /**
  3234. * Gets a child using its type and its name
  3235. * @param name defines the child name to look for
  3236. * @param type defines the child type to look for
  3237. * @returns the child control if found
  3238. */
  3239. Container.prototype.getChildByType = function (name, type) {
  3240. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3241. var child = _a[_i];
  3242. if (child.typeName === type) {
  3243. return child;
  3244. }
  3245. }
  3246. return null;
  3247. };
  3248. /**
  3249. * Search for a specific control in children
  3250. * @param control defines the control to look for
  3251. * @returns true if the control is in child list
  3252. */
  3253. Container.prototype.containsControl = function (control) {
  3254. return this.children.indexOf(control) !== -1;
  3255. };
  3256. /**
  3257. * Adds a new control to the current container
  3258. * @param control defines the control to add
  3259. * @returns the current container
  3260. */
  3261. Container.prototype.addControl = function (control) {
  3262. if (!control) {
  3263. return this;
  3264. }
  3265. var index = this._children.indexOf(control);
  3266. if (index !== -1) {
  3267. return this;
  3268. }
  3269. control._link(this._host);
  3270. control._markAllAsDirty();
  3271. this._reOrderControl(control);
  3272. this._markAsDirty();
  3273. return this;
  3274. };
  3275. /**
  3276. * Removes all controls from the current container
  3277. * @returns the current container
  3278. */
  3279. Container.prototype.clearControls = function () {
  3280. var children = this.children.slice();
  3281. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3282. var child = children_1[_i];
  3283. this.removeControl(child);
  3284. }
  3285. return this;
  3286. };
  3287. /**
  3288. * Removes a control from the current container
  3289. * @param control defines the control to remove
  3290. * @returns the current container
  3291. */
  3292. Container.prototype.removeControl = function (control) {
  3293. var index = this._children.indexOf(control);
  3294. if (index !== -1) {
  3295. this._children.splice(index, 1);
  3296. control.parent = null;
  3297. }
  3298. control.linkWithMesh(null);
  3299. if (this._host) {
  3300. this._host._cleanControlAfterRemoval(control);
  3301. }
  3302. this._markAsDirty();
  3303. return this;
  3304. };
  3305. /** @hidden */
  3306. Container.prototype._reOrderControl = function (control) {
  3307. this.removeControl(control);
  3308. var wasAdded = false;
  3309. for (var index = 0; index < this._children.length; index++) {
  3310. if (this._children[index].zIndex > control.zIndex) {
  3311. this._children.splice(index, 0, control);
  3312. wasAdded = true;
  3313. break;
  3314. }
  3315. }
  3316. if (!wasAdded) {
  3317. this._children.push(control);
  3318. }
  3319. control.parent = this;
  3320. this._markAsDirty();
  3321. };
  3322. /** @hidden */
  3323. Container.prototype._offsetLeft = function (offset) {
  3324. _super.prototype._offsetLeft.call(this, offset);
  3325. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3326. var child = _a[_i];
  3327. child._offsetLeft(offset);
  3328. }
  3329. };
  3330. /** @hidden */
  3331. Container.prototype._offsetTop = function (offset) {
  3332. _super.prototype._offsetTop.call(this, offset);
  3333. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3334. var child = _a[_i];
  3335. child._offsetTop(offset);
  3336. }
  3337. };
  3338. /** @hidden */
  3339. Container.prototype._markAllAsDirty = function () {
  3340. _super.prototype._markAllAsDirty.call(this);
  3341. for (var index = 0; index < this._children.length; index++) {
  3342. this._children[index]._markAllAsDirty();
  3343. }
  3344. };
  3345. /** @hidden */
  3346. Container.prototype._localDraw = function (context) {
  3347. if (this._background) {
  3348. context.save();
  3349. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3350. context.shadowColor = this.shadowColor;
  3351. context.shadowBlur = this.shadowBlur;
  3352. context.shadowOffsetX = this.shadowOffsetX;
  3353. context.shadowOffsetY = this.shadowOffsetY;
  3354. }
  3355. context.fillStyle = this._background;
  3356. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3357. context.restore();
  3358. }
  3359. };
  3360. /** @hidden */
  3361. Container.prototype._link = function (host) {
  3362. _super.prototype._link.call(this, host);
  3363. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3364. var child = _a[_i];
  3365. child._link(host);
  3366. }
  3367. };
  3368. /** @hidden */
  3369. Container.prototype._beforeLayout = function () {
  3370. // Do nothing
  3371. };
  3372. /** @hidden */
  3373. Container.prototype._processMeasures = function (parentMeasure, context) {
  3374. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3375. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3376. this._evaluateClippingState(parentMeasure);
  3377. }
  3378. };
  3379. /** @hidden */
  3380. Container.prototype._layout = function (parentMeasure, context) {
  3381. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3382. return false;
  3383. }
  3384. if (this._isDirty) {
  3385. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3386. }
  3387. var rebuildCount = 0;
  3388. context.save();
  3389. this._applyStates(context);
  3390. this._beforeLayout();
  3391. do {
  3392. var computedWidth = -1;
  3393. var computedHeight = -1;
  3394. this._rebuildLayout = false;
  3395. this._processMeasures(parentMeasure, context);
  3396. if (!this._isClipped) {
  3397. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3398. var child = _a[_i];
  3399. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3400. if (child._layout(this._measureForChildren, context)) {
  3401. if (this.adaptWidthToChildren && child._width.isPixel) {
  3402. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3403. }
  3404. if (this.adaptHeightToChildren && child._height.isPixel) {
  3405. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3406. }
  3407. }
  3408. }
  3409. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3410. if (this.width !== computedWidth + "px") {
  3411. this.width = computedWidth + "px";
  3412. this._rebuildLayout = true;
  3413. }
  3414. }
  3415. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3416. if (this.height !== computedHeight + "px") {
  3417. this.height = computedHeight + "px";
  3418. this._rebuildLayout = true;
  3419. }
  3420. }
  3421. this._postMeasure();
  3422. }
  3423. rebuildCount++;
  3424. } while (this._rebuildLayout && rebuildCount < 3);
  3425. if (rebuildCount >= 3) {
  3426. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3427. }
  3428. context.restore();
  3429. if (this._isDirty) {
  3430. this.invalidateRect();
  3431. this._isDirty = false;
  3432. }
  3433. return true;
  3434. };
  3435. Container.prototype._postMeasure = function () {
  3436. // Do nothing by default
  3437. };
  3438. /** @hidden */
  3439. Container.prototype._draw = function (context, invalidatedRectangle) {
  3440. this._localDraw(context);
  3441. if (this.clipChildren) {
  3442. this._clipForChildren(context);
  3443. }
  3444. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3445. var child = _a[_i];
  3446. // Only redraw parts of the screen that are invalidated
  3447. if (invalidatedRectangle) {
  3448. if (!child._intersectsRect(invalidatedRectangle)) {
  3449. continue;
  3450. }
  3451. }
  3452. child._render(context, invalidatedRectangle);
  3453. }
  3454. };
  3455. /** @hidden */
  3456. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3457. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3458. if (!this.children) {
  3459. return;
  3460. }
  3461. for (var index = 0; index < this.children.length; index++) {
  3462. var item = this.children[index];
  3463. if (!predicate || predicate(item)) {
  3464. results.push(item);
  3465. }
  3466. if (!directDescendantsOnly) {
  3467. item._getDescendants(results, false, predicate);
  3468. }
  3469. }
  3470. };
  3471. /** @hidden */
  3472. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3473. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3474. return false;
  3475. }
  3476. if (!_super.prototype.contains.call(this, x, y)) {
  3477. return false;
  3478. }
  3479. // Checking backwards to pick closest first
  3480. for (var index = this._children.length - 1; index >= 0; index--) {
  3481. var child = this._children[index];
  3482. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3483. if (child.hoverCursor) {
  3484. this._host._changeCursor(child.hoverCursor);
  3485. }
  3486. return true;
  3487. }
  3488. }
  3489. if (!this.isHitTestVisible) {
  3490. return false;
  3491. }
  3492. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3493. };
  3494. /** @hidden */
  3495. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3496. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3497. this._measureForChildren.copyFrom(this._currentMeasure);
  3498. };
  3499. /** Releases associated resources */
  3500. Container.prototype.dispose = function () {
  3501. _super.prototype.dispose.call(this);
  3502. for (var index = this.children.length - 1; index >= 0; index--) {
  3503. this.children[index].dispose();
  3504. }
  3505. };
  3506. return Container;
  3507. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3508. /***/ }),
  3509. /***/ "./2D/controls/control.ts":
  3510. /*!********************************!*\
  3511. !*** ./2D/controls/control.ts ***!
  3512. \********************************/
  3513. /*! exports provided: Control */
  3514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3515. "use strict";
  3516. __webpack_require__.r(__webpack_exports__);
  3517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3518. <<<<<<< HEAD
  3519. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  3520. =======
  3521. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  3522. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  3523. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3524. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3525. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3526. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3527. /**
  3528. * Root class used for all 2D controls
  3529. * @see http://doc.babylonjs.com/how_to/gui#controls
  3530. */
  3531. var Control = /** @class */ (function () {
  3532. // Functions
  3533. /**
  3534. * Creates a new control
  3535. * @param name defines the name of the control
  3536. */
  3537. function Control(
  3538. /** defines the name of the control */
  3539. name) {
  3540. this.name = name;
  3541. this._alpha = 1;
  3542. this._alphaSet = false;
  3543. this._zIndex = 0;
  3544. /** @hidden */
  3545. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3546. this._fontFamily = "Arial";
  3547. this._fontStyle = "";
  3548. this._fontWeight = "";
  3549. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3550. /** @hidden */
  3551. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3552. /** @hidden */
  3553. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3554. this._color = "";
  3555. this._style = null;
  3556. /** @hidden */
  3557. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3558. /** @hidden */
  3559. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3560. /** @hidden */
  3561. this._isDirty = true;
  3562. /** @hidden */
  3563. this._wasDirty = false;
  3564. /** @hidden */
  3565. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3566. /** @hidden */
  3567. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3568. /** @hidden */
  3569. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3570. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3571. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3572. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3573. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3574. /** @hidden */
  3575. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3576. /** @hidden */
  3577. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3578. this._scaleX = 1.0;
  3579. this._scaleY = 1.0;
  3580. this._rotation = 0;
  3581. this._transformCenterX = 0.5;
  3582. this._transformCenterY = 0.5;
  3583. /** @hidden */
  3584. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3585. /** @hidden */
  3586. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3587. /** @hidden */
  3588. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3589. this._isMatrixDirty = true;
  3590. this._isVisible = true;
  3591. this._isHighlighted = false;
  3592. this._fontSet = false;
  3593. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3594. this._downCount = 0;
  3595. this._enterCount = -1;
  3596. this._doNotRender = false;
  3597. this._downPointerIds = {};
  3598. this._isEnabled = true;
  3599. this._disabledColor = "#9a9a9a";
  3600. /** @hidden */
  3601. this._rebuildLayout = false;
  3602. /** @hidden */
  3603. this._isClipped = false;
  3604. /**
  3605. * Gets or sets an object used to store user defined information for the node
  3606. */
  3607. this.metadata = null;
  3608. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3609. this.isHitTestVisible = true;
  3610. /** Gets or sets a boolean indicating if the control can block pointer events */
  3611. this.isPointerBlocker = false;
  3612. /** Gets or sets a boolean indicating if the control can be focusable */
  3613. this.isFocusInvisible = false;
  3614. /**
  3615. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3616. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  3617. */
  3618. this.clipChildren = true;
  3619. /**
  3620. * Gets or sets a boolean indicating that control content must be clipped
  3621. * 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
  3622. */
  3623. this.clipContent = true;
  3624. /**
  3625. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3626. */
  3627. this.useBitmapCache = false;
  3628. this._shadowOffsetX = 0;
  3629. this._shadowOffsetY = 0;
  3630. this._shadowBlur = 0;
  3631. this._shadowColor = 'black';
  3632. /** Gets or sets the cursor to use when the control is hovered */
  3633. this.hoverCursor = "";
  3634. /** @hidden */
  3635. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3636. /** @hidden */
  3637. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3638. /**
  3639. * An event triggered when the pointer move over the control.
  3640. */
  3641. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3642. /**
  3643. * An event triggered when the pointer move out of the control.
  3644. */
  3645. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3646. /**
  3647. * An event triggered when the pointer taps the control
  3648. */
  3649. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3650. /**
  3651. * An event triggered when pointer up
  3652. */
  3653. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3654. /**
  3655. * An event triggered when a control is clicked on
  3656. */
  3657. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3658. /**
  3659. * An event triggered when pointer enters the control
  3660. */
  3661. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3662. /**
  3663. * An event triggered when the control is marked as dirty
  3664. */
  3665. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3666. /**
  3667. * An event triggered before drawing the control
  3668. */
  3669. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3670. /**
  3671. * An event triggered after the control was drawn
  3672. */
  3673. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3674. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3675. }
  3676. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3677. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3678. get: function () {
  3679. return this._shadowOffsetX;
  3680. },
  3681. set: function (value) {
  3682. if (this._shadowOffsetX === value) {
  3683. return;
  3684. }
  3685. this._shadowOffsetX = value;
  3686. this._markAsDirty();
  3687. },
  3688. enumerable: true,
  3689. configurable: true
  3690. });
  3691. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3692. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3693. get: function () {
  3694. return this._shadowOffsetY;
  3695. },
  3696. set: function (value) {
  3697. if (this._shadowOffsetY === value) {
  3698. return;
  3699. }
  3700. this._shadowOffsetY = value;
  3701. this._markAsDirty();
  3702. },
  3703. enumerable: true,
  3704. configurable: true
  3705. });
  3706. Object.defineProperty(Control.prototype, "shadowBlur", {
  3707. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3708. get: function () {
  3709. return this._shadowBlur;
  3710. },
  3711. set: function (value) {
  3712. if (this._shadowBlur === value) {
  3713. return;
  3714. }
  3715. this._shadowBlur = value;
  3716. this._markAsDirty();
  3717. },
  3718. enumerable: true,
  3719. configurable: true
  3720. });
  3721. Object.defineProperty(Control.prototype, "shadowColor", {
  3722. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3723. get: function () {
  3724. return this._shadowColor;
  3725. },
  3726. set: function (value) {
  3727. if (this._shadowColor === value) {
  3728. return;
  3729. }
  3730. this._shadowColor = value;
  3731. this._markAsDirty();
  3732. },
  3733. enumerable: true,
  3734. configurable: true
  3735. });
  3736. Object.defineProperty(Control.prototype, "typeName", {
  3737. // Properties
  3738. /** Gets the control type name */
  3739. get: function () {
  3740. return this._getTypeName();
  3741. },
  3742. enumerable: true,
  3743. configurable: true
  3744. });
  3745. /**
  3746. * Get the current class name of the control.
  3747. * @returns current class name
  3748. */
  3749. Control.prototype.getClassName = function () {
  3750. return this._getTypeName();
  3751. };
  3752. Object.defineProperty(Control.prototype, "host", {
  3753. /**
  3754. * Get the hosting AdvancedDynamicTexture
  3755. */
  3756. get: function () {
  3757. return this._host;
  3758. },
  3759. enumerable: true,
  3760. configurable: true
  3761. });
  3762. Object.defineProperty(Control.prototype, "fontOffset", {
  3763. /** Gets or set information about font offsets (used to render and align text) */
  3764. get: function () {
  3765. return this._fontOffset;
  3766. },
  3767. set: function (offset) {
  3768. this._fontOffset = offset;
  3769. },
  3770. enumerable: true,
  3771. configurable: true
  3772. });
  3773. Object.defineProperty(Control.prototype, "alpha", {
  3774. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3775. get: function () {
  3776. return this._alpha;
  3777. },
  3778. set: function (value) {
  3779. if (this._alpha === value) {
  3780. return;
  3781. }
  3782. this._alphaSet = true;
  3783. this._alpha = value;
  3784. this._markAsDirty();
  3785. },
  3786. enumerable: true,
  3787. configurable: true
  3788. });
  3789. Object.defineProperty(Control.prototype, "isHighlighted", {
  3790. /**
  3791. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3792. */
  3793. get: function () {
  3794. return this._isHighlighted;
  3795. },
  3796. set: function (value) {
  3797. if (this._isHighlighted === value) {
  3798. return;
  3799. }
  3800. this._isHighlighted = value;
  3801. this._markAsDirty();
  3802. },
  3803. enumerable: true,
  3804. configurable: true
  3805. });
  3806. Object.defineProperty(Control.prototype, "scaleX", {
  3807. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3808. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3809. */
  3810. get: function () {
  3811. return this._scaleX;
  3812. },
  3813. set: function (value) {
  3814. if (this._scaleX === value) {
  3815. return;
  3816. }
  3817. this._scaleX = value;
  3818. this._markAsDirty();
  3819. this._markMatrixAsDirty();
  3820. },
  3821. enumerable: true,
  3822. configurable: true
  3823. });
  3824. Object.defineProperty(Control.prototype, "scaleY", {
  3825. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3826. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3827. */
  3828. get: function () {
  3829. return this._scaleY;
  3830. },
  3831. set: function (value) {
  3832. if (this._scaleY === value) {
  3833. return;
  3834. }
  3835. this._scaleY = value;
  3836. this._markAsDirty();
  3837. this._markMatrixAsDirty();
  3838. },
  3839. enumerable: true,
  3840. configurable: true
  3841. });
  3842. Object.defineProperty(Control.prototype, "rotation", {
  3843. /** Gets or sets the rotation angle (0 by default)
  3844. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3845. */
  3846. get: function () {
  3847. return this._rotation;
  3848. },
  3849. set: function (value) {
  3850. if (this._rotation === value) {
  3851. return;
  3852. }
  3853. this._rotation = value;
  3854. this._markAsDirty();
  3855. this._markMatrixAsDirty();
  3856. },
  3857. enumerable: true,
  3858. configurable: true
  3859. });
  3860. Object.defineProperty(Control.prototype, "transformCenterY", {
  3861. /** Gets or sets the transformation center on Y axis (0 by default)
  3862. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3863. */
  3864. get: function () {
  3865. return this._transformCenterY;
  3866. },
  3867. set: function (value) {
  3868. if (this._transformCenterY === value) {
  3869. return;
  3870. }
  3871. this._transformCenterY = value;
  3872. this._markAsDirty();
  3873. this._markMatrixAsDirty();
  3874. },
  3875. enumerable: true,
  3876. configurable: true
  3877. });
  3878. Object.defineProperty(Control.prototype, "transformCenterX", {
  3879. /** Gets or sets the transformation center on X axis (0 by default)
  3880. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3881. */
  3882. get: function () {
  3883. return this._transformCenterX;
  3884. },
  3885. set: function (value) {
  3886. if (this._transformCenterX === value) {
  3887. return;
  3888. }
  3889. this._transformCenterX = value;
  3890. this._markAsDirty();
  3891. this._markMatrixAsDirty();
  3892. },
  3893. enumerable: true,
  3894. configurable: true
  3895. });
  3896. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3897. /**
  3898. * Gets or sets the horizontal alignment
  3899. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3900. */
  3901. get: function () {
  3902. return this._horizontalAlignment;
  3903. },
  3904. set: function (value) {
  3905. if (this._horizontalAlignment === value) {
  3906. return;
  3907. }
  3908. this._horizontalAlignment = value;
  3909. this._markAsDirty();
  3910. },
  3911. enumerable: true,
  3912. configurable: true
  3913. });
  3914. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3915. /**
  3916. * Gets or sets the vertical alignment
  3917. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3918. */
  3919. get: function () {
  3920. return this._verticalAlignment;
  3921. },
  3922. set: function (value) {
  3923. if (this._verticalAlignment === value) {
  3924. return;
  3925. }
  3926. this._verticalAlignment = value;
  3927. this._markAsDirty();
  3928. },
  3929. enumerable: true,
  3930. configurable: true
  3931. });
  3932. Object.defineProperty(Control.prototype, "width", {
  3933. /**
  3934. * Gets or sets control width
  3935. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3936. */
  3937. get: function () {
  3938. return this._width.toString(this._host);
  3939. },
  3940. set: function (value) {
  3941. if (this._width.toString(this._host) === value) {
  3942. return;
  3943. }
  3944. if (this._width.fromString(value)) {
  3945. this._markAsDirty();
  3946. }
  3947. },
  3948. enumerable: true,
  3949. configurable: true
  3950. });
  3951. Object.defineProperty(Control.prototype, "widthInPixels", {
  3952. /**
  3953. * Gets or sets the control width in pixel
  3954. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3955. */
  3956. get: function () {
  3957. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3958. },
  3959. set: function (value) {
  3960. if (isNaN(value)) {
  3961. return;
  3962. }
  3963. this.width = value + "px";
  3964. },
  3965. enumerable: true,
  3966. configurable: true
  3967. });
  3968. Object.defineProperty(Control.prototype, "height", {
  3969. /**
  3970. * Gets or sets control height
  3971. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3972. */
  3973. get: function () {
  3974. return this._height.toString(this._host);
  3975. },
  3976. set: function (value) {
  3977. if (this._height.toString(this._host) === value) {
  3978. return;
  3979. }
  3980. if (this._height.fromString(value)) {
  3981. this._markAsDirty();
  3982. }
  3983. },
  3984. enumerable: true,
  3985. configurable: true
  3986. });
  3987. Object.defineProperty(Control.prototype, "heightInPixels", {
  3988. /**
  3989. * Gets or sets control height in pixel
  3990. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3991. */
  3992. get: function () {
  3993. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  3994. },
  3995. set: function (value) {
  3996. if (isNaN(value)) {
  3997. return;
  3998. }
  3999. this.height = value + "px";
  4000. },
  4001. enumerable: true,
  4002. configurable: true
  4003. });
  4004. Object.defineProperty(Control.prototype, "fontFamily", {
  4005. /** Gets or set font family */
  4006. get: function () {
  4007. if (!this._fontSet) {
  4008. return "";
  4009. }
  4010. return this._fontFamily;
  4011. },
  4012. set: function (value) {
  4013. if (this._fontFamily === value) {
  4014. return;
  4015. }
  4016. this._fontFamily = value;
  4017. this._resetFontCache();
  4018. },
  4019. enumerable: true,
  4020. configurable: true
  4021. });
  4022. Object.defineProperty(Control.prototype, "fontStyle", {
  4023. /** Gets or sets font style */
  4024. get: function () {
  4025. return this._fontStyle;
  4026. },
  4027. set: function (value) {
  4028. if (this._fontStyle === value) {
  4029. return;
  4030. }
  4031. this._fontStyle = value;
  4032. this._resetFontCache();
  4033. },
  4034. enumerable: true,
  4035. configurable: true
  4036. });
  4037. Object.defineProperty(Control.prototype, "fontWeight", {
  4038. /** Gets or sets font weight */
  4039. get: function () {
  4040. return this._fontWeight;
  4041. },
  4042. set: function (value) {
  4043. if (this._fontWeight === value) {
  4044. return;
  4045. }
  4046. this._fontWeight = value;
  4047. this._resetFontCache();
  4048. },
  4049. enumerable: true,
  4050. configurable: true
  4051. });
  4052. Object.defineProperty(Control.prototype, "style", {
  4053. /**
  4054. * Gets or sets style
  4055. * @see http://doc.babylonjs.com/how_to/gui#styles
  4056. */
  4057. get: function () {
  4058. return this._style;
  4059. },
  4060. set: function (value) {
  4061. var _this = this;
  4062. if (this._style) {
  4063. this._style.onChangedObservable.remove(this._styleObserver);
  4064. this._styleObserver = null;
  4065. }
  4066. this._style = value;
  4067. if (this._style) {
  4068. this._styleObserver = this._style.onChangedObservable.add(function () {
  4069. _this._markAsDirty();
  4070. _this._resetFontCache();
  4071. });
  4072. }
  4073. this._markAsDirty();
  4074. this._resetFontCache();
  4075. },
  4076. enumerable: true,
  4077. configurable: true
  4078. });
  4079. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4080. /** @hidden */
  4081. get: function () {
  4082. return this._fontSize.isPercentage;
  4083. },
  4084. enumerable: true,
  4085. configurable: true
  4086. });
  4087. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4088. /** Gets or sets font size in pixels */
  4089. get: function () {
  4090. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4091. if (fontSizeToUse.isPixel) {
  4092. return fontSizeToUse.getValue(this._host);
  4093. }
  4094. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4095. },
  4096. set: function (value) {
  4097. if (isNaN(value)) {
  4098. return;
  4099. }
  4100. this.fontSize = value + "px";
  4101. },
  4102. enumerable: true,
  4103. configurable: true
  4104. });
  4105. Object.defineProperty(Control.prototype, "fontSize", {
  4106. /** Gets or sets font size */
  4107. get: function () {
  4108. return this._fontSize.toString(this._host);
  4109. },
  4110. set: function (value) {
  4111. if (this._fontSize.toString(this._host) === value) {
  4112. return;
  4113. }
  4114. if (this._fontSize.fromString(value)) {
  4115. this._markAsDirty();
  4116. this._resetFontCache();
  4117. }
  4118. },
  4119. enumerable: true,
  4120. configurable: true
  4121. });
  4122. Object.defineProperty(Control.prototype, "color", {
  4123. /** Gets or sets foreground color */
  4124. get: function () {
  4125. return this._color;
  4126. },
  4127. set: function (value) {
  4128. if (this._color === value) {
  4129. return;
  4130. }
  4131. this._color = value;
  4132. this._markAsDirty();
  4133. },
  4134. enumerable: true,
  4135. configurable: true
  4136. });
  4137. Object.defineProperty(Control.prototype, "zIndex", {
  4138. /** Gets or sets z index which is used to reorder controls on the z axis */
  4139. get: function () {
  4140. return this._zIndex;
  4141. },
  4142. set: function (value) {
  4143. if (this.zIndex === value) {
  4144. return;
  4145. }
  4146. this._zIndex = value;
  4147. if (this.parent) {
  4148. this.parent._reOrderControl(this);
  4149. }
  4150. },
  4151. enumerable: true,
  4152. configurable: true
  4153. });
  4154. Object.defineProperty(Control.prototype, "notRenderable", {
  4155. /** Gets or sets a boolean indicating if the control can be rendered */
  4156. get: function () {
  4157. return this._doNotRender;
  4158. },
  4159. set: function (value) {
  4160. if (this._doNotRender === value) {
  4161. return;
  4162. }
  4163. this._doNotRender = value;
  4164. this._markAsDirty();
  4165. },
  4166. enumerable: true,
  4167. configurable: true
  4168. });
  4169. Object.defineProperty(Control.prototype, "isVisible", {
  4170. /** Gets or sets a boolean indicating if the control is visible */
  4171. get: function () {
  4172. return this._isVisible;
  4173. },
  4174. set: function (value) {
  4175. if (this._isVisible === value) {
  4176. return;
  4177. }
  4178. this._isVisible = value;
  4179. this._markAsDirty(true);
  4180. },
  4181. enumerable: true,
  4182. configurable: true
  4183. });
  4184. Object.defineProperty(Control.prototype, "isDirty", {
  4185. /** Gets a boolean indicating that the control needs to update its rendering */
  4186. get: function () {
  4187. return this._isDirty;
  4188. },
  4189. enumerable: true,
  4190. configurable: true
  4191. });
  4192. Object.defineProperty(Control.prototype, "linkedMesh", {
  4193. /**
  4194. * Gets the current linked mesh (or null if none)
  4195. */
  4196. get: function () {
  4197. return this._linkedMesh;
  4198. },
  4199. enumerable: true,
  4200. configurable: true
  4201. });
  4202. Object.defineProperty(Control.prototype, "paddingLeft", {
  4203. /**
  4204. * Gets or sets a value indicating the padding to use on the left of the control
  4205. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4206. */
  4207. get: function () {
  4208. return this._paddingLeft.toString(this._host);
  4209. },
  4210. set: function (value) {
  4211. if (this._paddingLeft.fromString(value)) {
  4212. this._markAsDirty();
  4213. }
  4214. },
  4215. enumerable: true,
  4216. configurable: true
  4217. });
  4218. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4219. /**
  4220. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4221. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4222. */
  4223. get: function () {
  4224. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4225. },
  4226. set: function (value) {
  4227. if (isNaN(value)) {
  4228. return;
  4229. }
  4230. this.paddingLeft = value + "px";
  4231. },
  4232. enumerable: true,
  4233. configurable: true
  4234. });
  4235. Object.defineProperty(Control.prototype, "paddingRight", {
  4236. /**
  4237. * Gets or sets a value indicating the padding to use on the right of the control
  4238. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4239. */
  4240. get: function () {
  4241. return this._paddingRight.toString(this._host);
  4242. },
  4243. set: function (value) {
  4244. if (this._paddingRight.fromString(value)) {
  4245. this._markAsDirty();
  4246. }
  4247. },
  4248. enumerable: true,
  4249. configurable: true
  4250. });
  4251. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4252. /**
  4253. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4254. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4255. */
  4256. get: function () {
  4257. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4258. },
  4259. set: function (value) {
  4260. if (isNaN(value)) {
  4261. return;
  4262. }
  4263. this.paddingRight = value + "px";
  4264. },
  4265. enumerable: true,
  4266. configurable: true
  4267. });
  4268. Object.defineProperty(Control.prototype, "paddingTop", {
  4269. /**
  4270. * Gets or sets a value indicating the padding to use on the top of the control
  4271. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4272. */
  4273. get: function () {
  4274. return this._paddingTop.toString(this._host);
  4275. },
  4276. set: function (value) {
  4277. if (this._paddingTop.fromString(value)) {
  4278. this._markAsDirty();
  4279. }
  4280. },
  4281. enumerable: true,
  4282. configurable: true
  4283. });
  4284. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4285. /**
  4286. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4287. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4288. */
  4289. get: function () {
  4290. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4291. },
  4292. set: function (value) {
  4293. if (isNaN(value)) {
  4294. return;
  4295. }
  4296. this.paddingTop = value + "px";
  4297. },
  4298. enumerable: true,
  4299. configurable: true
  4300. });
  4301. Object.defineProperty(Control.prototype, "paddingBottom", {
  4302. /**
  4303. * Gets or sets a value indicating the padding to use on the bottom of the control
  4304. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4305. */
  4306. get: function () {
  4307. return this._paddingBottom.toString(this._host);
  4308. },
  4309. set: function (value) {
  4310. if (this._paddingBottom.fromString(value)) {
  4311. this._markAsDirty();
  4312. }
  4313. },
  4314. enumerable: true,
  4315. configurable: true
  4316. });
  4317. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4318. /**
  4319. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4320. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4321. */
  4322. get: function () {
  4323. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4324. },
  4325. set: function (value) {
  4326. if (isNaN(value)) {
  4327. return;
  4328. }
  4329. this.paddingBottom = value + "px";
  4330. },
  4331. enumerable: true,
  4332. configurable: true
  4333. });
  4334. Object.defineProperty(Control.prototype, "left", {
  4335. /**
  4336. * Gets or sets a value indicating the left coordinate of the control
  4337. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4338. */
  4339. get: function () {
  4340. return this._left.toString(this._host);
  4341. },
  4342. set: function (value) {
  4343. if (this._left.fromString(value)) {
  4344. this._markAsDirty();
  4345. }
  4346. },
  4347. enumerable: true,
  4348. configurable: true
  4349. });
  4350. Object.defineProperty(Control.prototype, "leftInPixels", {
  4351. /**
  4352. * Gets or sets a value indicating the left coordinate in pixels of the control
  4353. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4354. */
  4355. get: function () {
  4356. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4357. },
  4358. set: function (value) {
  4359. if (isNaN(value)) {
  4360. return;
  4361. }
  4362. this.left = value + "px";
  4363. },
  4364. enumerable: true,
  4365. configurable: true
  4366. });
  4367. Object.defineProperty(Control.prototype, "top", {
  4368. /**
  4369. * Gets or sets a value indicating the top coordinate of the control
  4370. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4371. */
  4372. get: function () {
  4373. return this._top.toString(this._host);
  4374. },
  4375. set: function (value) {
  4376. if (this._top.fromString(value)) {
  4377. this._markAsDirty();
  4378. }
  4379. },
  4380. enumerable: true,
  4381. configurable: true
  4382. });
  4383. Object.defineProperty(Control.prototype, "topInPixels", {
  4384. /**
  4385. * Gets or sets a value indicating the top coordinate in pixels of the control
  4386. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4387. */
  4388. get: function () {
  4389. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4390. },
  4391. set: function (value) {
  4392. if (isNaN(value)) {
  4393. return;
  4394. }
  4395. this.top = value + "px";
  4396. },
  4397. enumerable: true,
  4398. configurable: true
  4399. });
  4400. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4401. /**
  4402. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4403. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4404. */
  4405. get: function () {
  4406. return this._linkOffsetX.toString(this._host);
  4407. },
  4408. set: function (value) {
  4409. if (this._linkOffsetX.fromString(value)) {
  4410. this._markAsDirty();
  4411. }
  4412. },
  4413. enumerable: true,
  4414. configurable: true
  4415. });
  4416. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4417. /**
  4418. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4419. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4420. */
  4421. get: function () {
  4422. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4423. },
  4424. set: function (value) {
  4425. if (isNaN(value)) {
  4426. return;
  4427. }
  4428. this.linkOffsetX = value + "px";
  4429. },
  4430. enumerable: true,
  4431. configurable: true
  4432. });
  4433. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4434. /**
  4435. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4436. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4437. */
  4438. get: function () {
  4439. return this._linkOffsetY.toString(this._host);
  4440. },
  4441. set: function (value) {
  4442. if (this._linkOffsetY.fromString(value)) {
  4443. this._markAsDirty();
  4444. }
  4445. },
  4446. enumerable: true,
  4447. configurable: true
  4448. });
  4449. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4450. /**
  4451. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4452. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4453. */
  4454. get: function () {
  4455. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4456. },
  4457. set: function (value) {
  4458. if (isNaN(value)) {
  4459. return;
  4460. }
  4461. this.linkOffsetY = value + "px";
  4462. },
  4463. enumerable: true,
  4464. configurable: true
  4465. });
  4466. Object.defineProperty(Control.prototype, "centerX", {
  4467. /** Gets the center coordinate on X axis */
  4468. get: function () {
  4469. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4470. },
  4471. enumerable: true,
  4472. configurable: true
  4473. });
  4474. Object.defineProperty(Control.prototype, "centerY", {
  4475. /** Gets the center coordinate on Y axis */
  4476. get: function () {
  4477. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4478. },
  4479. enumerable: true,
  4480. configurable: true
  4481. });
  4482. Object.defineProperty(Control.prototype, "isEnabled", {
  4483. /** Gets or sets if control is Enabled*/
  4484. get: function () {
  4485. return this._isEnabled;
  4486. },
  4487. set: function (value) {
  4488. if (this._isEnabled === value) {
  4489. return;
  4490. }
  4491. this._isEnabled = value;
  4492. this._markAsDirty();
  4493. },
  4494. enumerable: true,
  4495. configurable: true
  4496. });
  4497. Object.defineProperty(Control.prototype, "disabledColor", {
  4498. /** Gets or sets background color of control if it's disabled*/
  4499. get: function () {
  4500. return this._disabledColor;
  4501. },
  4502. set: function (value) {
  4503. if (this._disabledColor === value) {
  4504. return;
  4505. }
  4506. this._disabledColor = value;
  4507. this._markAsDirty();
  4508. },
  4509. enumerable: true,
  4510. configurable: true
  4511. });
  4512. /** @hidden */
  4513. Control.prototype._getTypeName = function () {
  4514. return "Control";
  4515. };
  4516. /**
  4517. * Gets the first ascendant in the hierarchy of the given type
  4518. * @param className defines the required type
  4519. * @returns the ascendant or null if not found
  4520. */
  4521. Control.prototype.getAscendantOfClass = function (className) {
  4522. if (!this.parent) {
  4523. return null;
  4524. }
  4525. if (this.parent.getClassName() === className) {
  4526. return this.parent;
  4527. }
  4528. return this.parent.getAscendantOfClass(className);
  4529. };
  4530. /** @hidden */
  4531. Control.prototype._resetFontCache = function () {
  4532. this._fontSet = true;
  4533. this._markAsDirty();
  4534. };
  4535. /**
  4536. * Determines if a container is an ascendant of the current control
  4537. * @param container defines the container to look for
  4538. * @returns true if the container is one of the ascendant of the control
  4539. */
  4540. Control.prototype.isAscendant = function (container) {
  4541. if (!this.parent) {
  4542. return false;
  4543. }
  4544. if (this.parent === container) {
  4545. return true;
  4546. }
  4547. return this.parent.isAscendant(container);
  4548. };
  4549. /**
  4550. * Gets coordinates in local control space
  4551. * @param globalCoordinates defines the coordinates to transform
  4552. * @returns the new coordinates in local space
  4553. */
  4554. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4555. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4556. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4557. return result;
  4558. };
  4559. /**
  4560. * Gets coordinates in local control space
  4561. * @param globalCoordinates defines the coordinates to transform
  4562. * @param result defines the target vector2 where to store the result
  4563. * @returns the current control
  4564. */
  4565. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4566. result.x = globalCoordinates.x - this._currentMeasure.left;
  4567. result.y = globalCoordinates.y - this._currentMeasure.top;
  4568. return this;
  4569. };
  4570. /**
  4571. * Gets coordinates in parent local control space
  4572. * @param globalCoordinates defines the coordinates to transform
  4573. * @returns the new coordinates in parent local space
  4574. */
  4575. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4576. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4577. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4578. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4579. return result;
  4580. };
  4581. /**
  4582. * Move the current control to a vector3 position projected onto the screen.
  4583. * @param position defines the target position
  4584. * @param scene defines the hosting scene
  4585. */
  4586. Control.prototype.moveToVector3 = function (position, scene) {
  4587. if (!this._host || this.parent !== this._host._rootContainer) {
  4588. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4589. return;
  4590. }
  4591. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4592. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4593. var globalViewport = this._host._getGlobalViewport(scene);
  4594. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4595. this._moveToProjectedPosition(projectedPosition);
  4596. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4597. this.notRenderable = true;
  4598. return;
  4599. }
  4600. this.notRenderable = false;
  4601. };
  4602. /** @hidden */
  4603. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4604. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4605. // Do nothing by default
  4606. };
  4607. /**
  4608. * Will return all controls that have this control as ascendant
  4609. * @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
  4610. * @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
  4611. * @return all child controls
  4612. */
  4613. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4614. var results = new Array();
  4615. this._getDescendants(results, directDescendantsOnly, predicate);
  4616. return results;
  4617. };
  4618. /**
  4619. * Link current control with a target mesh
  4620. * @param mesh defines the mesh to link with
  4621. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4622. */
  4623. Control.prototype.linkWithMesh = function (mesh) {
  4624. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4625. if (mesh) {
  4626. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4627. }
  4628. return;
  4629. }
  4630. var index = this._host._linkedControls.indexOf(this);
  4631. if (index !== -1) {
  4632. this._linkedMesh = mesh;
  4633. if (!mesh) {
  4634. this._host._linkedControls.splice(index, 1);
  4635. }
  4636. return;
  4637. }
  4638. else if (!mesh) {
  4639. return;
  4640. }
  4641. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4642. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4643. this._linkedMesh = mesh;
  4644. this._host._linkedControls.push(this);
  4645. };
  4646. /** @hidden */
  4647. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4648. var oldLeft = this._left.getValue(this._host);
  4649. var oldTop = this._top.getValue(this._host);
  4650. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4651. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4652. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4653. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4654. newLeft = oldLeft;
  4655. }
  4656. if (Math.abs(newTop - oldTop) < 0.5) {
  4657. newTop = oldTop;
  4658. }
  4659. }
  4660. this.left = newLeft + "px";
  4661. this.top = newTop + "px";
  4662. this._left.ignoreAdaptiveScaling = true;
  4663. this._top.ignoreAdaptiveScaling = true;
  4664. this._markAsDirty();
  4665. };
  4666. /** @hidden */
  4667. Control.prototype._offsetLeft = function (offset) {
  4668. this._isDirty = true;
  4669. this._currentMeasure.left += offset;
  4670. };
  4671. /** @hidden */
  4672. Control.prototype._offsetTop = function (offset) {
  4673. this._isDirty = true;
  4674. this._currentMeasure.top += offset;
  4675. };
  4676. /** @hidden */
  4677. Control.prototype._markMatrixAsDirty = function () {
  4678. this._isMatrixDirty = true;
  4679. this._flagDescendantsAsMatrixDirty();
  4680. };
  4681. /** @hidden */
  4682. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4683. // No child
  4684. };
  4685. /** @hidden */
  4686. Control.prototype._intersectsRect = function (rect) {
  4687. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4688. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4689. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4690. return false;
  4691. }
  4692. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4693. return false;
  4694. }
  4695. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4696. return false;
  4697. }
  4698. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4699. return false;
  4700. }
  4701. return true;
  4702. };
  4703. /** @hidden */
  4704. Control.prototype.invalidateRect = function () {
  4705. this._transform();
  4706. if (this.host && this.host.useInvalidateRectOptimization) {
  4707. // Rotate by transform to get the measure transformed to global space
  4708. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4709. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4710. // the previous measure is used to properly clear a control that is scaled down
  4711. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4712. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4713. // Expand rect based on shadows
  4714. var shadowOffsetX = this.shadowOffsetX;
  4715. var shadowOffsetY = this.shadowOffsetY;
  4716. var shadowBlur = this.shadowBlur;
  4717. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4718. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4719. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4720. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4721. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left + leftShadowOffset), Math.floor(this._tmpMeasureA.top + topShadowOffset), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width + rightShadowOffset), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height + bottomShadowOffset));
  4722. }
  4723. else {
  4724. 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));
  4725. }
  4726. }
  4727. };
  4728. /** @hidden */
  4729. Control.prototype._markAsDirty = function (force) {
  4730. if (force === void 0) { force = false; }
  4731. if (!this._isVisible && !force) {
  4732. return;
  4733. }
  4734. this._isDirty = true;
  4735. // Redraw only this rectangle
  4736. if (this._host) {
  4737. this._host.markAsDirty();
  4738. }
  4739. };
  4740. /** @hidden */
  4741. Control.prototype._markAllAsDirty = function () {
  4742. this._markAsDirty();
  4743. if (this._font) {
  4744. this._prepareFont();
  4745. }
  4746. };
  4747. /** @hidden */
  4748. Control.prototype._link = function (host) {
  4749. this._host = host;
  4750. if (this._host) {
  4751. this.uniqueId = this._host.getScene().getUniqueId();
  4752. }
  4753. };
  4754. /** @hidden */
  4755. Control.prototype._transform = function (context) {
  4756. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4757. return;
  4758. }
  4759. // postTranslate
  4760. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4761. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4762. if (context) {
  4763. context.translate(offsetX, offsetY);
  4764. // rotate
  4765. context.rotate(this._rotation);
  4766. // scale
  4767. context.scale(this._scaleX, this._scaleY);
  4768. // preTranslate
  4769. context.translate(-offsetX, -offsetY);
  4770. }
  4771. // Need to update matrices?
  4772. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4773. this._cachedOffsetX = offsetX;
  4774. this._cachedOffsetY = offsetY;
  4775. this._isMatrixDirty = false;
  4776. this._flagDescendantsAsMatrixDirty();
  4777. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4778. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4779. }
  4780. };
  4781. /** @hidden */
  4782. Control.prototype._renderHighlight = function (context) {
  4783. if (!this.isHighlighted) {
  4784. return;
  4785. }
  4786. context.save();
  4787. context.strokeStyle = "#4affff";
  4788. context.lineWidth = 2;
  4789. this._renderHighlightSpecific(context);
  4790. context.restore();
  4791. };
  4792. /** @hidden */
  4793. Control.prototype._renderHighlightSpecific = function (context) {
  4794. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4795. };
  4796. /** @hidden */
  4797. Control.prototype._applyStates = function (context) {
  4798. if (this._isFontSizeInPercentage) {
  4799. this._fontSet = true;
  4800. }
  4801. if (this._fontSet) {
  4802. this._prepareFont();
  4803. this._fontSet = false;
  4804. }
  4805. if (this._font) {
  4806. context.font = this._font;
  4807. }
  4808. if (this._color) {
  4809. context.fillStyle = this._color;
  4810. }
  4811. if (Control.AllowAlphaInheritance) {
  4812. context.globalAlpha *= this._alpha;
  4813. }
  4814. else if (this._alphaSet) {
  4815. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4816. }
  4817. };
  4818. /** @hidden */
  4819. Control.prototype._layout = function (parentMeasure, context) {
  4820. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4821. return false;
  4822. }
  4823. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4824. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4825. context.save();
  4826. this._applyStates(context);
  4827. var rebuildCount = 0;
  4828. do {
  4829. this._rebuildLayout = false;
  4830. this._processMeasures(parentMeasure, context);
  4831. rebuildCount++;
  4832. } while (this._rebuildLayout && rebuildCount < 3);
  4833. if (rebuildCount >= 3) {
  4834. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4835. }
  4836. context.restore();
  4837. this.invalidateRect();
  4838. this._evaluateClippingState(parentMeasure);
  4839. }
  4840. this._wasDirty = this._isDirty;
  4841. this._isDirty = false;
  4842. return true;
  4843. };
  4844. /** @hidden */
  4845. Control.prototype._processMeasures = function (parentMeasure, context) {
  4846. this._currentMeasure.copyFrom(parentMeasure);
  4847. // Let children take some pre-measurement actions
  4848. this._preMeasure(parentMeasure, context);
  4849. this._measure();
  4850. this._computeAlignment(parentMeasure, context);
  4851. // Convert to int values
  4852. this._currentMeasure.left = this._currentMeasure.left | 0;
  4853. this._currentMeasure.top = this._currentMeasure.top | 0;
  4854. this._currentMeasure.width = this._currentMeasure.width | 0;
  4855. this._currentMeasure.height = this._currentMeasure.height | 0;
  4856. // Let children add more features
  4857. this._additionalProcessing(parentMeasure, context);
  4858. this._cachedParentMeasure.copyFrom(parentMeasure);
  4859. if (this.onDirtyObservable.hasObservers()) {
  4860. this.onDirtyObservable.notifyObservers(this);
  4861. }
  4862. };
  4863. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4864. if (this.parent && this.parent.clipChildren) {
  4865. // Early clip
  4866. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4867. this._isClipped = true;
  4868. return;
  4869. }
  4870. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4871. this._isClipped = true;
  4872. return;
  4873. }
  4874. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4875. this._isClipped = true;
  4876. return;
  4877. }
  4878. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4879. this._isClipped = true;
  4880. return;
  4881. }
  4882. }
  4883. this._isClipped = false;
  4884. };
  4885. /** @hidden */
  4886. Control.prototype._measure = function () {
  4887. // Width / Height
  4888. if (this._width.isPixel) {
  4889. this._currentMeasure.width = this._width.getValue(this._host);
  4890. }
  4891. else {
  4892. this._currentMeasure.width *= this._width.getValue(this._host);
  4893. }
  4894. if (this._height.isPixel) {
  4895. this._currentMeasure.height = this._height.getValue(this._host);
  4896. }
  4897. else {
  4898. this._currentMeasure.height *= this._height.getValue(this._host);
  4899. }
  4900. };
  4901. /** @hidden */
  4902. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4903. var width = this._currentMeasure.width;
  4904. var height = this._currentMeasure.height;
  4905. var parentWidth = parentMeasure.width;
  4906. var parentHeight = parentMeasure.height;
  4907. // Left / top
  4908. var x = 0;
  4909. var y = 0;
  4910. switch (this.horizontalAlignment) {
  4911. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4912. x = 0;
  4913. break;
  4914. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4915. x = parentWidth - width;
  4916. break;
  4917. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4918. x = (parentWidth - width) / 2;
  4919. break;
  4920. }
  4921. switch (this.verticalAlignment) {
  4922. case Control.VERTICAL_ALIGNMENT_TOP:
  4923. y = 0;
  4924. break;
  4925. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4926. y = parentHeight - height;
  4927. break;
  4928. case Control.VERTICAL_ALIGNMENT_CENTER:
  4929. y = (parentHeight - height) / 2;
  4930. break;
  4931. }
  4932. if (this._paddingLeft.isPixel) {
  4933. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4934. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4935. }
  4936. else {
  4937. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4938. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4939. }
  4940. if (this._paddingRight.isPixel) {
  4941. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4942. }
  4943. else {
  4944. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4945. }
  4946. if (this._paddingTop.isPixel) {
  4947. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4948. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4949. }
  4950. else {
  4951. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4952. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4953. }
  4954. if (this._paddingBottom.isPixel) {
  4955. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4956. }
  4957. else {
  4958. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4959. }
  4960. if (this._left.isPixel) {
  4961. this._currentMeasure.left += this._left.getValue(this._host);
  4962. }
  4963. else {
  4964. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4965. }
  4966. if (this._top.isPixel) {
  4967. this._currentMeasure.top += this._top.getValue(this._host);
  4968. }
  4969. else {
  4970. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4971. }
  4972. this._currentMeasure.left += x;
  4973. this._currentMeasure.top += y;
  4974. };
  4975. /** @hidden */
  4976. Control.prototype._preMeasure = function (parentMeasure, context) {
  4977. // Do nothing
  4978. };
  4979. /** @hidden */
  4980. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4981. // Do nothing
  4982. };
  4983. /** @hidden */
  4984. Control.prototype._clipForChildren = function (context) {
  4985. // DO nothing
  4986. };
  4987. Control.prototype._clip = function (context, invalidatedRectangle) {
  4988. context.beginPath();
  4989. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4990. if (invalidatedRectangle) {
  4991. // Rotate the invalidated rect into the control's space
  4992. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  4993. // Get the intersection of the rect in context space and the current context
  4994. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  4995. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  4996. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  4997. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  4998. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  4999. Control._ClipMeasure.copyFrom(intersection);
  5000. }
  5001. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5002. var shadowOffsetX = this.shadowOffsetX;
  5003. var shadowOffsetY = this.shadowOffsetY;
  5004. var shadowBlur = this.shadowBlur;
  5005. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5006. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5007. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5008. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5009. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5010. }
  5011. else {
  5012. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5013. }
  5014. context.clip();
  5015. };
  5016. /** @hidden */
  5017. Control.prototype._render = function (context, invalidatedRectangle) {
  5018. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5019. this._isDirty = false;
  5020. return false;
  5021. }
  5022. context.save();
  5023. this._applyStates(context);
  5024. // Transform
  5025. this._transform(context);
  5026. // Clip
  5027. if (this.clipContent) {
  5028. this._clip(context, invalidatedRectangle);
  5029. }
  5030. if (this.onBeforeDrawObservable.hasObservers()) {
  5031. this.onBeforeDrawObservable.notifyObservers(this);
  5032. }
  5033. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5034. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5035. }
  5036. else {
  5037. this._draw(context, invalidatedRectangle);
  5038. }
  5039. if (this.useBitmapCache && this._wasDirty) {
  5040. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5041. }
  5042. this._renderHighlight(context);
  5043. if (this.onAfterDrawObservable.hasObservers()) {
  5044. this.onAfterDrawObservable.notifyObservers(this);
  5045. }
  5046. context.restore();
  5047. return true;
  5048. };
  5049. /** @hidden */
  5050. Control.prototype._draw = function (context, invalidatedRectangle) {
  5051. // Do nothing
  5052. };
  5053. /**
  5054. * Tests if a given coordinates belong to the current control
  5055. * @param x defines x coordinate to test
  5056. * @param y defines y coordinate to test
  5057. * @returns true if the coordinates are inside the control
  5058. */
  5059. Control.prototype.contains = function (x, y) {
  5060. // Invert transform
  5061. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5062. x = this._transformedPosition.x;
  5063. y = this._transformedPosition.y;
  5064. // Check
  5065. if (x < this._currentMeasure.left) {
  5066. return false;
  5067. }
  5068. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5069. return false;
  5070. }
  5071. if (y < this._currentMeasure.top) {
  5072. return false;
  5073. }
  5074. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5075. return false;
  5076. }
  5077. if (this.isPointerBlocker) {
  5078. this._host._shouldBlockPointer = true;
  5079. }
  5080. return true;
  5081. };
  5082. /** @hidden */
  5083. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5084. if (!this._isEnabled) {
  5085. return false;
  5086. }
  5087. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5088. return false;
  5089. }
  5090. if (!this.contains(x, y)) {
  5091. return false;
  5092. }
  5093. this._processObservables(type, x, y, pointerId, buttonIndex);
  5094. return true;
  5095. };
  5096. /** @hidden */
  5097. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5098. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5099. if (canNotify && this.parent != null) {
  5100. this.parent._onPointerMove(target, coordinates, pointerId);
  5101. }
  5102. };
  5103. /** @hidden */
  5104. Control.prototype._onPointerEnter = function (target) {
  5105. if (!this._isEnabled) {
  5106. return false;
  5107. }
  5108. if (this._enterCount > 0) {
  5109. return false;
  5110. }
  5111. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5112. this._enterCount = 0;
  5113. }
  5114. this._enterCount++;
  5115. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5116. if (canNotify && this.parent != null) {
  5117. this.parent._onPointerEnter(target);
  5118. }
  5119. return true;
  5120. };
  5121. /** @hidden */
  5122. Control.prototype._onPointerOut = function (target, force) {
  5123. if (force === void 0) { force = false; }
  5124. if (!force && (!this._isEnabled || target === this)) {
  5125. return;
  5126. }
  5127. this._enterCount = 0;
  5128. var canNotify = true;
  5129. if (!target.isAscendant(this)) {
  5130. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5131. }
  5132. if (canNotify && this.parent != null) {
  5133. this.parent._onPointerOut(target, force);
  5134. }
  5135. };
  5136. /** @hidden */
  5137. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5138. // Prevent pointerout to lose control context.
  5139. // Event redundancy is checked inside the function.
  5140. this._onPointerEnter(this);
  5141. if (this._downCount !== 0) {
  5142. return false;
  5143. }
  5144. this._downCount++;
  5145. this._downPointerIds[pointerId] = true;
  5146. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5147. if (canNotify && this.parent != null) {
  5148. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5149. }
  5150. return true;
  5151. };
  5152. /** @hidden */
  5153. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5154. if (!this._isEnabled) {
  5155. return;
  5156. }
  5157. this._downCount = 0;
  5158. delete this._downPointerIds[pointerId];
  5159. var canNotifyClick = notifyClick;
  5160. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5161. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5162. }
  5163. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5164. if (canNotify && this.parent != null) {
  5165. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5166. }
  5167. };
  5168. /** @hidden */
  5169. Control.prototype._forcePointerUp = function (pointerId) {
  5170. if (pointerId === void 0) { pointerId = null; }
  5171. if (pointerId !== null) {
  5172. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5173. }
  5174. else {
  5175. for (var key in this._downPointerIds) {
  5176. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5177. }
  5178. }
  5179. };
  5180. /** @hidden */
  5181. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5182. if (!this._isEnabled) {
  5183. return false;
  5184. }
  5185. this._dummyVector2.copyFromFloats(x, y);
  5186. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5187. this._onPointerMove(this, this._dummyVector2, pointerId);
  5188. var previousControlOver = this._host._lastControlOver[pointerId];
  5189. if (previousControlOver && previousControlOver !== this) {
  5190. previousControlOver._onPointerOut(this);
  5191. }
  5192. if (previousControlOver !== this) {
  5193. this._onPointerEnter(this);
  5194. }
  5195. this._host._lastControlOver[pointerId] = this;
  5196. return true;
  5197. }
  5198. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5199. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5200. this._host._registerLastControlDown(this, pointerId);
  5201. this._host._lastPickedControl = this;
  5202. return true;
  5203. }
  5204. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5205. if (this._host._lastControlDown[pointerId]) {
  5206. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5207. }
  5208. delete this._host._lastControlDown[pointerId];
  5209. return true;
  5210. }
  5211. return false;
  5212. };
  5213. Control.prototype._prepareFont = function () {
  5214. if (!this._font && !this._fontSet) {
  5215. return;
  5216. }
  5217. if (this._style) {
  5218. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5219. }
  5220. else {
  5221. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5222. }
  5223. this._fontOffset = Control._GetFontOffset(this._font);
  5224. };
  5225. /** Releases associated resources */
  5226. Control.prototype.dispose = function () {
  5227. this.onDirtyObservable.clear();
  5228. this.onBeforeDrawObservable.clear();
  5229. this.onAfterDrawObservable.clear();
  5230. this.onPointerDownObservable.clear();
  5231. this.onPointerEnterObservable.clear();
  5232. this.onPointerMoveObservable.clear();
  5233. this.onPointerOutObservable.clear();
  5234. this.onPointerUpObservable.clear();
  5235. this.onPointerClickObservable.clear();
  5236. if (this._styleObserver && this._style) {
  5237. this._style.onChangedObservable.remove(this._styleObserver);
  5238. this._styleObserver = null;
  5239. }
  5240. if (this.parent) {
  5241. this.parent.removeControl(this);
  5242. this.parent = null;
  5243. }
  5244. if (this._host) {
  5245. var index = this._host._linkedControls.indexOf(this);
  5246. if (index > -1) {
  5247. this.linkWithMesh(null);
  5248. }
  5249. }
  5250. };
  5251. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5252. /** HORIZONTAL_ALIGNMENT_LEFT */
  5253. get: function () {
  5254. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5255. },
  5256. enumerable: true,
  5257. configurable: true
  5258. });
  5259. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5260. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5261. get: function () {
  5262. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5263. },
  5264. enumerable: true,
  5265. configurable: true
  5266. });
  5267. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5268. /** HORIZONTAL_ALIGNMENT_CENTER */
  5269. get: function () {
  5270. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5271. },
  5272. enumerable: true,
  5273. configurable: true
  5274. });
  5275. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5276. /** VERTICAL_ALIGNMENT_TOP */
  5277. get: function () {
  5278. return Control._VERTICAL_ALIGNMENT_TOP;
  5279. },
  5280. enumerable: true,
  5281. configurable: true
  5282. });
  5283. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5284. /** VERTICAL_ALIGNMENT_BOTTOM */
  5285. get: function () {
  5286. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5287. },
  5288. enumerable: true,
  5289. configurable: true
  5290. });
  5291. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5292. /** VERTICAL_ALIGNMENT_CENTER */
  5293. get: function () {
  5294. return Control._VERTICAL_ALIGNMENT_CENTER;
  5295. },
  5296. enumerable: true,
  5297. configurable: true
  5298. });
  5299. /** @hidden */
  5300. Control._GetFontOffset = function (font) {
  5301. if (Control._FontHeightSizes[font]) {
  5302. return Control._FontHeightSizes[font];
  5303. }
  5304. var text = document.createElement("span");
  5305. text.innerHTML = "Hg";
  5306. text.style.font = font;
  5307. var block = document.createElement("div");
  5308. block.style.display = "inline-block";
  5309. block.style.width = "1px";
  5310. block.style.height = "0px";
  5311. block.style.verticalAlign = "bottom";
  5312. var div = document.createElement("div");
  5313. div.appendChild(text);
  5314. div.appendChild(block);
  5315. document.body.appendChild(div);
  5316. var fontAscent = 0;
  5317. var fontHeight = 0;
  5318. try {
  5319. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5320. block.style.verticalAlign = "baseline";
  5321. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5322. }
  5323. finally {
  5324. document.body.removeChild(div);
  5325. }
  5326. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5327. Control._FontHeightSizes[font] = result;
  5328. return result;
  5329. };
  5330. /** @hidden */
  5331. Control.drawEllipse = function (x, y, width, height, context) {
  5332. context.translate(x, y);
  5333. context.scale(width, height);
  5334. context.beginPath();
  5335. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5336. context.closePath();
  5337. context.scale(1 / width, 1 / height);
  5338. context.translate(-x, -y);
  5339. };
  5340. /**
  5341. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5342. */
  5343. Control.AllowAlphaInheritance = false;
  5344. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5345. // Statics
  5346. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5347. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5348. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5349. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5350. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5351. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5352. Control._FontHeightSizes = {};
  5353. /**
  5354. * Creates a stack panel that can be used to render headers
  5355. * @param control defines the control to associate with the header
  5356. * @param text defines the text of the header
  5357. * @param size defines the size of the header
  5358. * @param options defines options used to configure the header
  5359. * @returns a new StackPanel
  5360. * @ignore
  5361. * @hidden
  5362. */
  5363. Control.AddHeader = function () { };
  5364. return Control;
  5365. }());
  5366. /***/ }),
  5367. /***/ "./2D/controls/displayGrid.ts":
  5368. /*!************************************!*\
  5369. !*** ./2D/controls/displayGrid.ts ***!
  5370. \************************************/
  5371. /*! exports provided: DisplayGrid */
  5372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5373. "use strict";
  5374. __webpack_require__.r(__webpack_exports__);
  5375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5376. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5377. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5378. /** Class used to render a grid */
  5379. var DisplayGrid = /** @class */ (function (_super) {
  5380. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5381. /**
  5382. * Creates a new GridDisplayRectangle
  5383. * @param name defines the control name
  5384. */
  5385. function DisplayGrid(name) {
  5386. var _this = _super.call(this, name) || this;
  5387. _this.name = name;
  5388. _this._cellWidth = 20;
  5389. _this._cellHeight = 20;
  5390. _this._minorLineTickness = 1;
  5391. _this._minorLineColor = "DarkGray";
  5392. _this._majorLineTickness = 2;
  5393. _this._majorLineColor = "White";
  5394. _this._majorLineFrequency = 5;
  5395. _this._background = "Black";
  5396. _this._displayMajorLines = true;
  5397. _this._displayMinorLines = true;
  5398. return _this;
  5399. }
  5400. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5401. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5402. get: function () {
  5403. return this._displayMinorLines;
  5404. },
  5405. set: function (value) {
  5406. if (this._displayMinorLines === value) {
  5407. return;
  5408. }
  5409. this._displayMinorLines = value;
  5410. this._markAsDirty();
  5411. },
  5412. enumerable: true,
  5413. configurable: true
  5414. });
  5415. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5416. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5417. get: function () {
  5418. return this._displayMajorLines;
  5419. },
  5420. set: function (value) {
  5421. if (this._displayMajorLines === value) {
  5422. return;
  5423. }
  5424. this._displayMajorLines = value;
  5425. this._markAsDirty();
  5426. },
  5427. enumerable: true,
  5428. configurable: true
  5429. });
  5430. Object.defineProperty(DisplayGrid.prototype, "background", {
  5431. /** Gets or sets background color (Black by default) */
  5432. get: function () {
  5433. return this._background;
  5434. },
  5435. set: function (value) {
  5436. if (this._background === value) {
  5437. return;
  5438. }
  5439. this._background = value;
  5440. this._markAsDirty();
  5441. },
  5442. enumerable: true,
  5443. configurable: true
  5444. });
  5445. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5446. /** Gets or sets the width of each cell (20 by default) */
  5447. get: function () {
  5448. return this._cellWidth;
  5449. },
  5450. set: function (value) {
  5451. this._cellWidth = value;
  5452. this._markAsDirty();
  5453. },
  5454. enumerable: true,
  5455. configurable: true
  5456. });
  5457. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5458. /** Gets or sets the height of each cell (20 by default) */
  5459. get: function () {
  5460. return this._cellHeight;
  5461. },
  5462. set: function (value) {
  5463. this._cellHeight = value;
  5464. this._markAsDirty();
  5465. },
  5466. enumerable: true,
  5467. configurable: true
  5468. });
  5469. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5470. /** Gets or sets the tickness of minor lines (1 by default) */
  5471. get: function () {
  5472. return this._minorLineTickness;
  5473. },
  5474. set: function (value) {
  5475. this._minorLineTickness = value;
  5476. this._markAsDirty();
  5477. },
  5478. enumerable: true,
  5479. configurable: true
  5480. });
  5481. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5482. /** Gets or sets the color of minor lines (DarkGray by default) */
  5483. get: function () {
  5484. return this._minorLineColor;
  5485. },
  5486. set: function (value) {
  5487. this._minorLineColor = value;
  5488. this._markAsDirty();
  5489. },
  5490. enumerable: true,
  5491. configurable: true
  5492. });
  5493. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5494. /** Gets or sets the tickness of major lines (2 by default) */
  5495. get: function () {
  5496. return this._majorLineTickness;
  5497. },
  5498. set: function (value) {
  5499. this._majorLineTickness = value;
  5500. this._markAsDirty();
  5501. },
  5502. enumerable: true,
  5503. configurable: true
  5504. });
  5505. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5506. /** Gets or sets the color of major lines (White by default) */
  5507. get: function () {
  5508. return this._majorLineColor;
  5509. },
  5510. set: function (value) {
  5511. this._majorLineColor = value;
  5512. this._markAsDirty();
  5513. },
  5514. enumerable: true,
  5515. configurable: true
  5516. });
  5517. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5518. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5519. get: function () {
  5520. return this._majorLineFrequency;
  5521. },
  5522. set: function (value) {
  5523. this._majorLineFrequency = value;
  5524. this._markAsDirty();
  5525. },
  5526. enumerable: true,
  5527. configurable: true
  5528. });
  5529. DisplayGrid.prototype._draw = function (context) {
  5530. context.save();
  5531. this._applyStates(context);
  5532. if (this._isEnabled) {
  5533. if (this._background) {
  5534. context.fillStyle = this._background;
  5535. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5536. }
  5537. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5538. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5539. // Minor lines
  5540. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5541. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5542. if (this._displayMinorLines) {
  5543. context.strokeStyle = this._minorLineColor;
  5544. context.lineWidth = this._minorLineTickness;
  5545. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5546. var cellX = left + x * this.cellWidth;
  5547. context.beginPath();
  5548. context.moveTo(cellX, this._currentMeasure.top);
  5549. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5550. context.stroke();
  5551. }
  5552. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5553. var cellY = top_1 + y * this.cellHeight;
  5554. context.beginPath();
  5555. context.moveTo(this._currentMeasure.left, cellY);
  5556. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5557. context.stroke();
  5558. }
  5559. }
  5560. // Major lines
  5561. if (this._displayMajorLines) {
  5562. context.strokeStyle = this._majorLineColor;
  5563. context.lineWidth = this._majorLineTickness;
  5564. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5565. var cellX = left + x * this.cellWidth;
  5566. context.beginPath();
  5567. context.moveTo(cellX, this._currentMeasure.top);
  5568. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5569. context.stroke();
  5570. }
  5571. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5572. var cellY = top_1 + y * this.cellHeight;
  5573. context.moveTo(this._currentMeasure.left, cellY);
  5574. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5575. context.closePath();
  5576. context.stroke();
  5577. }
  5578. }
  5579. }
  5580. context.restore();
  5581. };
  5582. DisplayGrid.prototype._getTypeName = function () {
  5583. return "DisplayGrid";
  5584. };
  5585. return DisplayGrid;
  5586. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5587. /***/ }),
  5588. /***/ "./2D/controls/ellipse.ts":
  5589. /*!********************************!*\
  5590. !*** ./2D/controls/ellipse.ts ***!
  5591. \********************************/
  5592. /*! exports provided: Ellipse */
  5593. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5594. "use strict";
  5595. __webpack_require__.r(__webpack_exports__);
  5596. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5597. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5598. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5599. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5600. /** Class used to create 2D ellipse containers */
  5601. var Ellipse = /** @class */ (function (_super) {
  5602. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5603. /**
  5604. * Creates a new Ellipse
  5605. * @param name defines the control name
  5606. */
  5607. function Ellipse(name) {
  5608. var _this = _super.call(this, name) || this;
  5609. _this.name = name;
  5610. _this._thickness = 1;
  5611. return _this;
  5612. }
  5613. Object.defineProperty(Ellipse.prototype, "thickness", {
  5614. /** Gets or sets border thickness */
  5615. get: function () {
  5616. return this._thickness;
  5617. },
  5618. set: function (value) {
  5619. if (this._thickness === value) {
  5620. return;
  5621. }
  5622. this._thickness = value;
  5623. this._markAsDirty();
  5624. },
  5625. enumerable: true,
  5626. configurable: true
  5627. });
  5628. Ellipse.prototype._getTypeName = function () {
  5629. return "Ellipse";
  5630. };
  5631. Ellipse.prototype._localDraw = function (context) {
  5632. context.save();
  5633. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5634. context.shadowColor = this.shadowColor;
  5635. context.shadowBlur = this.shadowBlur;
  5636. context.shadowOffsetX = this.shadowOffsetX;
  5637. context.shadowOffsetY = this.shadowOffsetY;
  5638. }
  5639. _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);
  5640. if (this._background) {
  5641. context.fillStyle = this._background;
  5642. context.fill();
  5643. }
  5644. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5645. context.shadowBlur = 0;
  5646. context.shadowOffsetX = 0;
  5647. context.shadowOffsetY = 0;
  5648. }
  5649. if (this._thickness) {
  5650. if (this.color) {
  5651. context.strokeStyle = this.color;
  5652. }
  5653. context.lineWidth = this._thickness;
  5654. context.stroke();
  5655. }
  5656. context.restore();
  5657. };
  5658. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5659. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5660. this._measureForChildren.width -= 2 * this._thickness;
  5661. this._measureForChildren.height -= 2 * this._thickness;
  5662. this._measureForChildren.left += this._thickness;
  5663. this._measureForChildren.top += this._thickness;
  5664. };
  5665. Ellipse.prototype._clipForChildren = function (context) {
  5666. _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);
  5667. context.clip();
  5668. };
  5669. return Ellipse;
  5670. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5671. /***/ }),
  5672. /***/ "./2D/controls/grid.ts":
  5673. /*!*****************************!*\
  5674. !*** ./2D/controls/grid.ts ***!
  5675. \*****************************/
  5676. /*! exports provided: Grid */
  5677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5678. "use strict";
  5679. __webpack_require__.r(__webpack_exports__);
  5680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5681. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5682. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5683. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5684. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5685. <<<<<<< HEAD
  5686. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  5687. =======
  5688. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  5689. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  5690. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5691. /**
  5692. * Class used to create a 2D grid container
  5693. */
  5694. var Grid = /** @class */ (function (_super) {
  5695. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5696. /**
  5697. * Creates a new Grid
  5698. * @param name defines control name
  5699. */
  5700. function Grid(name) {
  5701. var _this = _super.call(this, name) || this;
  5702. _this.name = name;
  5703. _this._rowDefinitions = new Array();
  5704. _this._columnDefinitions = new Array();
  5705. _this._cells = {};
  5706. _this._childControls = new Array();
  5707. return _this;
  5708. }
  5709. Object.defineProperty(Grid.prototype, "columnCount", {
  5710. /**
  5711. * Gets the number of columns
  5712. */
  5713. get: function () {
  5714. return this._columnDefinitions.length;
  5715. },
  5716. enumerable: true,
  5717. configurable: true
  5718. });
  5719. Object.defineProperty(Grid.prototype, "rowCount", {
  5720. /**
  5721. * Gets the number of rows
  5722. */
  5723. get: function () {
  5724. return this._rowDefinitions.length;
  5725. },
  5726. enumerable: true,
  5727. configurable: true
  5728. });
  5729. Object.defineProperty(Grid.prototype, "children", {
  5730. /** Gets the list of children */
  5731. get: function () {
  5732. return this._childControls;
  5733. },
  5734. enumerable: true,
  5735. configurable: true
  5736. });
  5737. Object.defineProperty(Grid.prototype, "cells", {
  5738. /** Gets the list of cells (e.g. the containers) */
  5739. get: function () {
  5740. return this._cells;
  5741. },
  5742. enumerable: true,
  5743. configurable: true
  5744. });
  5745. /**
  5746. * Gets the definition of a specific row
  5747. * @param index defines the index of the row
  5748. * @returns the row definition
  5749. */
  5750. Grid.prototype.getRowDefinition = function (index) {
  5751. if (index < 0 || index >= this._rowDefinitions.length) {
  5752. return null;
  5753. }
  5754. return this._rowDefinitions[index];
  5755. };
  5756. /**
  5757. * Gets the definition of a specific column
  5758. * @param index defines the index of the column
  5759. * @returns the column definition
  5760. */
  5761. Grid.prototype.getColumnDefinition = function (index) {
  5762. if (index < 0 || index >= this._columnDefinitions.length) {
  5763. return null;
  5764. }
  5765. return this._columnDefinitions[index];
  5766. };
  5767. /**
  5768. * Adds a new row to the grid
  5769. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5770. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5771. * @returns the current grid
  5772. */
  5773. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5774. if (isPixel === void 0) { isPixel = false; }
  5775. 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));
  5776. this._markAsDirty();
  5777. return this;
  5778. };
  5779. /**
  5780. * Adds a new column to the grid
  5781. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5782. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5783. * @returns the current grid
  5784. */
  5785. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5786. if (isPixel === void 0) { isPixel = false; }
  5787. 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));
  5788. this._markAsDirty();
  5789. return this;
  5790. };
  5791. /**
  5792. * Update a row definition
  5793. * @param index defines the index of the row to update
  5794. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5795. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5796. * @returns the current grid
  5797. */
  5798. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5799. if (isPixel === void 0) { isPixel = false; }
  5800. if (index < 0 || index >= this._rowDefinitions.length) {
  5801. return this;
  5802. }
  5803. var current = this._rowDefinitions[index];
  5804. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5805. return this;
  5806. }
  5807. 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);
  5808. this._markAsDirty();
  5809. return this;
  5810. };
  5811. /**
  5812. * Update a column definition
  5813. * @param index defines the index of the column to update
  5814. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5815. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5816. * @returns the current grid
  5817. */
  5818. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5819. if (isPixel === void 0) { isPixel = false; }
  5820. if (index < 0 || index >= this._columnDefinitions.length) {
  5821. return this;
  5822. }
  5823. var current = this._columnDefinitions[index];
  5824. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5825. return this;
  5826. }
  5827. 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);
  5828. this._markAsDirty();
  5829. return this;
  5830. };
  5831. /**
  5832. * Gets the list of children stored in a specific cell
  5833. * @param row defines the row to check
  5834. * @param column defines the column to check
  5835. * @returns the list of controls
  5836. */
  5837. Grid.prototype.getChildrenAt = function (row, column) {
  5838. var cell = this._cells[row + ":" + column];
  5839. if (!cell) {
  5840. return null;
  5841. }
  5842. return cell.children;
  5843. };
  5844. /**
  5845. * Gets a string representing the child cell info (row x column)
  5846. * @param child defines the control to get info from
  5847. * @returns a string containing the child cell info (row x column)
  5848. */
  5849. Grid.prototype.getChildCellInfo = function (child) {
  5850. return child._tag;
  5851. };
  5852. Grid.prototype._removeCell = function (cell, key) {
  5853. if (!cell) {
  5854. return;
  5855. }
  5856. _super.prototype.removeControl.call(this, cell);
  5857. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5858. var control = _a[_i];
  5859. var childIndex = this._childControls.indexOf(control);
  5860. if (childIndex !== -1) {
  5861. this._childControls.splice(childIndex, 1);
  5862. }
  5863. }
  5864. delete this._cells[key];
  5865. };
  5866. Grid.prototype._offsetCell = function (previousKey, key) {
  5867. if (!this._cells[key]) {
  5868. return;
  5869. }
  5870. this._cells[previousKey] = this._cells[key];
  5871. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5872. var control = _a[_i];
  5873. control._tag = previousKey;
  5874. }
  5875. delete this._cells[key];
  5876. };
  5877. /**
  5878. * Remove a column definition at specified index
  5879. * @param index defines the index of the column to remove
  5880. * @returns the current grid
  5881. */
  5882. Grid.prototype.removeColumnDefinition = function (index) {
  5883. if (index < 0 || index >= this._columnDefinitions.length) {
  5884. return this;
  5885. }
  5886. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5887. var key = x + ":" + index;
  5888. var cell = this._cells[key];
  5889. this._removeCell(cell, key);
  5890. }
  5891. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5892. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5893. var previousKey = x + ":" + (y - 1);
  5894. var key = x + ":" + y;
  5895. this._offsetCell(previousKey, key);
  5896. }
  5897. }
  5898. this._columnDefinitions.splice(index, 1);
  5899. this._markAsDirty();
  5900. return this;
  5901. };
  5902. /**
  5903. * Remove a row definition at specified index
  5904. * @param index defines the index of the row to remove
  5905. * @returns the current grid
  5906. */
  5907. Grid.prototype.removeRowDefinition = function (index) {
  5908. if (index < 0 || index >= this._rowDefinitions.length) {
  5909. return this;
  5910. }
  5911. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5912. var key = index + ":" + y;
  5913. var cell = this._cells[key];
  5914. this._removeCell(cell, key);
  5915. }
  5916. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5917. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5918. var previousKey = x - 1 + ":" + y;
  5919. var key = x + ":" + y;
  5920. this._offsetCell(previousKey, key);
  5921. }
  5922. }
  5923. this._rowDefinitions.splice(index, 1);
  5924. this._markAsDirty();
  5925. return this;
  5926. };
  5927. /**
  5928. * Adds a new control to the current grid
  5929. * @param control defines the control to add
  5930. * @param row defines the row where to add the control (0 by default)
  5931. * @param column defines the column where to add the control (0 by default)
  5932. * @returns the current grid
  5933. */
  5934. Grid.prototype.addControl = function (control, row, column) {
  5935. if (row === void 0) { row = 0; }
  5936. if (column === void 0) { column = 0; }
  5937. if (this._rowDefinitions.length === 0) {
  5938. // Add default row definition
  5939. this.addRowDefinition(1, false);
  5940. }
  5941. if (this._columnDefinitions.length === 0) {
  5942. // Add default column definition
  5943. this.addColumnDefinition(1, false);
  5944. }
  5945. if (this._childControls.indexOf(control) !== -1) {
  5946. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].Warn("Control (Name:" + control.name + ", UniqueId:" + control.uniqueId + ") is already associated with this grid. You must remove it before reattaching it");
  5947. return this;
  5948. }
  5949. var x = Math.min(row, this._rowDefinitions.length - 1);
  5950. var y = Math.min(column, this._columnDefinitions.length - 1);
  5951. var key = x + ":" + y;
  5952. var goodContainer = this._cells[key];
  5953. if (!goodContainer) {
  5954. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5955. this._cells[key] = goodContainer;
  5956. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5957. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5958. _super.prototype.addControl.call(this, goodContainer);
  5959. }
  5960. goodContainer.addControl(control);
  5961. this._childControls.push(control);
  5962. control._tag = key;
  5963. control.parent = this;
  5964. this._markAsDirty();
  5965. return this;
  5966. };
  5967. /**
  5968. * Removes a control from the current container
  5969. * @param control defines the control to remove
  5970. * @returns the current container
  5971. */
  5972. Grid.prototype.removeControl = function (control) {
  5973. var index = this._childControls.indexOf(control);
  5974. if (index !== -1) {
  5975. this._childControls.splice(index, 1);
  5976. }
  5977. var cell = this._cells[control._tag];
  5978. if (cell) {
  5979. cell.removeControl(control);
  5980. control._tag = null;
  5981. }
  5982. this._markAsDirty();
  5983. return this;
  5984. };
  5985. Grid.prototype._getTypeName = function () {
  5986. return "Grid";
  5987. };
  5988. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5989. var widths = [];
  5990. var heights = [];
  5991. var lefts = [];
  5992. var tops = [];
  5993. var availableWidth = this._currentMeasure.width;
  5994. var globalWidthPercentage = 0;
  5995. var availableHeight = this._currentMeasure.height;
  5996. var globalHeightPercentage = 0;
  5997. // Heights
  5998. var index = 0;
  5999. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6000. var value = _a[_i];
  6001. if (value.isPixel) {
  6002. var height = value.getValue(this._host);
  6003. availableHeight -= height;
  6004. heights[index] = height;
  6005. }
  6006. else {
  6007. globalHeightPercentage += value.internalValue;
  6008. }
  6009. index++;
  6010. }
  6011. var top = 0;
  6012. index = 0;
  6013. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6014. var value = _c[_b];
  6015. tops.push(top);
  6016. if (!value.isPixel) {
  6017. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6018. top += height;
  6019. heights[index] = height;
  6020. }
  6021. else {
  6022. top += value.getValue(this._host);
  6023. }
  6024. index++;
  6025. }
  6026. // Widths
  6027. index = 0;
  6028. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6029. var value = _e[_d];
  6030. if (value.isPixel) {
  6031. var width = value.getValue(this._host);
  6032. availableWidth -= width;
  6033. widths[index] = width;
  6034. }
  6035. else {
  6036. globalWidthPercentage += value.internalValue;
  6037. }
  6038. index++;
  6039. }
  6040. var left = 0;
  6041. index = 0;
  6042. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6043. var value = _g[_f];
  6044. lefts.push(left);
  6045. if (!value.isPixel) {
  6046. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6047. left += width;
  6048. widths[index] = width;
  6049. }
  6050. else {
  6051. left += value.getValue(this._host);
  6052. }
  6053. index++;
  6054. }
  6055. definitionCallback(lefts, tops, widths, heights);
  6056. };
  6057. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6058. var _this = this;
  6059. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6060. // Setting child sizes
  6061. for (var key in _this._cells) {
  6062. if (!_this._cells.hasOwnProperty(key)) {
  6063. continue;
  6064. }
  6065. var split = key.split(":");
  6066. var x = parseInt(split[0]);
  6067. var y = parseInt(split[1]);
  6068. var cell = _this._cells[key];
  6069. cell.left = lefts[y] + "px";
  6070. cell.top = tops[x] + "px";
  6071. cell.width = widths[y] + "px";
  6072. cell.height = heights[x] + "px";
  6073. cell._left.ignoreAdaptiveScaling = true;
  6074. cell._top.ignoreAdaptiveScaling = true;
  6075. cell._width.ignoreAdaptiveScaling = true;
  6076. cell._height.ignoreAdaptiveScaling = true;
  6077. }
  6078. });
  6079. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6080. };
  6081. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6082. for (var key in this._cells) {
  6083. if (!this._cells.hasOwnProperty(key)) {
  6084. continue;
  6085. }
  6086. var child = this._cells[key];
  6087. child._markMatrixAsDirty();
  6088. }
  6089. };
  6090. Grid.prototype._renderHighlightSpecific = function (context) {
  6091. var _this = this;
  6092. _super.prototype._renderHighlightSpecific.call(this, context);
  6093. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6094. // Columns
  6095. for (var index = 0; index < lefts.length; index++) {
  6096. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6097. context.beginPath();
  6098. context.moveTo(left, _this._currentMeasure.top);
  6099. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6100. context.stroke();
  6101. }
  6102. // Rows
  6103. for (var index = 0; index < tops.length; index++) {
  6104. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6105. context.beginPath();
  6106. context.moveTo(_this._currentMeasure.left, top_1);
  6107. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6108. context.stroke();
  6109. }
  6110. });
  6111. context.restore();
  6112. };
  6113. /** Releases associated resources */
  6114. Grid.prototype.dispose = function () {
  6115. _super.prototype.dispose.call(this);
  6116. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6117. var control = _a[_i];
  6118. control.dispose();
  6119. }
  6120. this._childControls = [];
  6121. };
  6122. return Grid;
  6123. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6124. /***/ }),
  6125. /***/ "./2D/controls/image.ts":
  6126. /*!******************************!*\
  6127. !*** ./2D/controls/image.ts ***!
  6128. \******************************/
  6129. /*! exports provided: Image */
  6130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6131. "use strict";
  6132. __webpack_require__.r(__webpack_exports__);
  6133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6134. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6135. <<<<<<< HEAD
  6136. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6137. =======
  6138. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  6139. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  6140. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6141. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6142. /**
  6143. * Class used to create 2D images
  6144. */
  6145. var Image = /** @class */ (function (_super) {
  6146. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6147. /**
  6148. * Creates a new Image
  6149. * @param name defines the control name
  6150. * @param url defines the image url
  6151. */
  6152. function Image(name, url) {
  6153. if (url === void 0) { url = null; }
  6154. var _this = _super.call(this, name) || this;
  6155. _this.name = name;
  6156. _this._loaded = false;
  6157. _this._stretch = Image.STRETCH_FILL;
  6158. _this._autoScale = false;
  6159. _this._sourceLeft = 0;
  6160. _this._sourceTop = 0;
  6161. _this._sourceWidth = 0;
  6162. _this._sourceHeight = 0;
  6163. _this._cellWidth = 0;
  6164. _this._cellHeight = 0;
  6165. _this._cellId = -1;
  6166. _this._populateNinePatchSlicesFromImage = false;
  6167. /**
  6168. * Observable notified when the content is loaded
  6169. */
  6170. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6171. _this.source = url;
  6172. return _this;
  6173. }
  6174. Object.defineProperty(Image.prototype, "isLoaded", {
  6175. /**
  6176. * Gets a boolean indicating that the content is loaded
  6177. */
  6178. get: function () {
  6179. return this._loaded;
  6180. },
  6181. enumerable: true,
  6182. configurable: true
  6183. });
  6184. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6185. /**
  6186. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6187. */
  6188. get: function () {
  6189. return this._populateNinePatchSlicesFromImage;
  6190. },
  6191. set: function (value) {
  6192. if (this._populateNinePatchSlicesFromImage === value) {
  6193. return;
  6194. }
  6195. this._populateNinePatchSlicesFromImage = value;
  6196. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6197. this._extractNinePatchSliceDataFromImage();
  6198. }
  6199. },
  6200. enumerable: true,
  6201. configurable: true
  6202. });
  6203. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6204. /**
  6205. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6206. * Beware using this as this will comsume more memory as the image has to be stored twice
  6207. */
  6208. get: function () {
  6209. return this._detectPointerOnOpaqueOnly;
  6210. },
  6211. set: function (value) {
  6212. if (this._detectPointerOnOpaqueOnly === value) {
  6213. return;
  6214. }
  6215. this._detectPointerOnOpaqueOnly = value;
  6216. },
  6217. enumerable: true,
  6218. configurable: true
  6219. });
  6220. Object.defineProperty(Image.prototype, "sliceLeft", {
  6221. /**
  6222. * Gets or sets the left value for slicing (9-patch)
  6223. */
  6224. get: function () {
  6225. return this._sliceLeft;
  6226. },
  6227. set: function (value) {
  6228. if (this._sliceLeft === value) {
  6229. return;
  6230. }
  6231. this._sliceLeft = value;
  6232. this._markAsDirty();
  6233. },
  6234. enumerable: true,
  6235. configurable: true
  6236. });
  6237. Object.defineProperty(Image.prototype, "sliceRight", {
  6238. /**
  6239. * Gets or sets the right value for slicing (9-patch)
  6240. */
  6241. get: function () {
  6242. return this._sliceRight;
  6243. },
  6244. set: function (value) {
  6245. if (this._sliceRight === value) {
  6246. return;
  6247. }
  6248. this._sliceRight = value;
  6249. this._markAsDirty();
  6250. },
  6251. enumerable: true,
  6252. configurable: true
  6253. });
  6254. Object.defineProperty(Image.prototype, "sliceTop", {
  6255. /**
  6256. * Gets or sets the top value for slicing (9-patch)
  6257. */
  6258. get: function () {
  6259. return this._sliceTop;
  6260. },
  6261. set: function (value) {
  6262. if (this._sliceTop === value) {
  6263. return;
  6264. }
  6265. this._sliceTop = value;
  6266. this._markAsDirty();
  6267. },
  6268. enumerable: true,
  6269. configurable: true
  6270. });
  6271. Object.defineProperty(Image.prototype, "sliceBottom", {
  6272. /**
  6273. * Gets or sets the bottom value for slicing (9-patch)
  6274. */
  6275. get: function () {
  6276. return this._sliceBottom;
  6277. },
  6278. set: function (value) {
  6279. if (this._sliceBottom === value) {
  6280. return;
  6281. }
  6282. this._sliceBottom = value;
  6283. this._markAsDirty();
  6284. },
  6285. enumerable: true,
  6286. configurable: true
  6287. });
  6288. Object.defineProperty(Image.prototype, "sourceLeft", {
  6289. /**
  6290. * Gets or sets the left coordinate in the source image
  6291. */
  6292. get: function () {
  6293. return this._sourceLeft;
  6294. },
  6295. set: function (value) {
  6296. if (this._sourceLeft === value) {
  6297. return;
  6298. }
  6299. this._sourceLeft = value;
  6300. this._markAsDirty();
  6301. },
  6302. enumerable: true,
  6303. configurable: true
  6304. });
  6305. Object.defineProperty(Image.prototype, "sourceTop", {
  6306. /**
  6307. * Gets or sets the top coordinate in the source image
  6308. */
  6309. get: function () {
  6310. return this._sourceTop;
  6311. },
  6312. set: function (value) {
  6313. if (this._sourceTop === value) {
  6314. return;
  6315. }
  6316. this._sourceTop = value;
  6317. this._markAsDirty();
  6318. },
  6319. enumerable: true,
  6320. configurable: true
  6321. });
  6322. Object.defineProperty(Image.prototype, "sourceWidth", {
  6323. /**
  6324. * Gets or sets the width to capture in the source image
  6325. */
  6326. get: function () {
  6327. return this._sourceWidth;
  6328. },
  6329. set: function (value) {
  6330. if (this._sourceWidth === value) {
  6331. return;
  6332. }
  6333. this._sourceWidth = value;
  6334. this._markAsDirty();
  6335. },
  6336. enumerable: true,
  6337. configurable: true
  6338. });
  6339. Object.defineProperty(Image.prototype, "sourceHeight", {
  6340. /**
  6341. * Gets or sets the height to capture in the source image
  6342. */
  6343. get: function () {
  6344. return this._sourceHeight;
  6345. },
  6346. set: function (value) {
  6347. if (this._sourceHeight === value) {
  6348. return;
  6349. }
  6350. this._sourceHeight = value;
  6351. this._markAsDirty();
  6352. },
  6353. enumerable: true,
  6354. configurable: true
  6355. });
  6356. Object.defineProperty(Image.prototype, "autoScale", {
  6357. /**
  6358. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6359. * @see http://doc.babylonjs.com/how_to/gui#image
  6360. */
  6361. get: function () {
  6362. return this._autoScale;
  6363. },
  6364. set: function (value) {
  6365. if (this._autoScale === value) {
  6366. return;
  6367. }
  6368. this._autoScale = value;
  6369. if (value && this._loaded) {
  6370. this.synchronizeSizeWithContent();
  6371. }
  6372. },
  6373. enumerable: true,
  6374. configurable: true
  6375. });
  6376. Object.defineProperty(Image.prototype, "stretch", {
  6377. /** Gets or sets the streching mode used by the image */
  6378. get: function () {
  6379. return this._stretch;
  6380. },
  6381. set: function (value) {
  6382. if (this._stretch === value) {
  6383. return;
  6384. }
  6385. this._stretch = value;
  6386. this._markAsDirty();
  6387. },
  6388. enumerable: true,
  6389. configurable: true
  6390. });
  6391. Object.defineProperty(Image.prototype, "domImage", {
  6392. get: function () {
  6393. return this._domImage;
  6394. },
  6395. /**
  6396. * Gets or sets the internal DOM image used to render the control
  6397. */
  6398. set: function (value) {
  6399. var _this = this;
  6400. this._domImage = value;
  6401. this._loaded = false;
  6402. if (this._domImage.width) {
  6403. this._onImageLoaded();
  6404. }
  6405. else {
  6406. this._domImage.onload = function () {
  6407. _this._onImageLoaded();
  6408. };
  6409. }
  6410. },
  6411. enumerable: true,
  6412. configurable: true
  6413. });
  6414. Image.prototype._onImageLoaded = function () {
  6415. this._imageWidth = this._domImage.width;
  6416. this._imageHeight = this._domImage.height;
  6417. this._loaded = true;
  6418. if (this._populateNinePatchSlicesFromImage) {
  6419. this._extractNinePatchSliceDataFromImage();
  6420. }
  6421. if (this._autoScale) {
  6422. this.synchronizeSizeWithContent();
  6423. }
  6424. this.onImageLoadedObservable.notifyObservers(this);
  6425. this._markAsDirty();
  6426. };
  6427. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6428. if (!Image._WorkingCanvas) {
  6429. Image._WorkingCanvas = document.createElement('canvas');
  6430. }
  6431. var canvas = Image._WorkingCanvas;
  6432. var context = canvas.getContext('2d');
  6433. var width = this._domImage.width;
  6434. var height = this._domImage.height;
  6435. canvas.width = width;
  6436. canvas.height = height;
  6437. context.drawImage(this._domImage, 0, 0, width, height);
  6438. var imageData = context.getImageData(0, 0, width, height);
  6439. // Left and right
  6440. this._sliceLeft = -1;
  6441. this._sliceRight = -1;
  6442. for (var x = 0; x < width; x++) {
  6443. var alpha = imageData.data[x * 4 + 3];
  6444. if (alpha > 127 && this._sliceLeft === -1) {
  6445. this._sliceLeft = x;
  6446. continue;
  6447. }
  6448. if (alpha < 127 && this._sliceLeft > -1) {
  6449. this._sliceRight = x;
  6450. break;
  6451. }
  6452. }
  6453. // top and bottom
  6454. this._sliceTop = -1;
  6455. this._sliceBottom = -1;
  6456. for (var y = 0; y < height; y++) {
  6457. var alpha = imageData.data[y * width * 4 + 3];
  6458. if (alpha > 127 && this._sliceTop === -1) {
  6459. this._sliceTop = y;
  6460. continue;
  6461. }
  6462. if (alpha < 127 && this._sliceTop > -1) {
  6463. this._sliceBottom = y;
  6464. break;
  6465. }
  6466. }
  6467. };
  6468. Object.defineProperty(Image.prototype, "source", {
  6469. /**
  6470. * Gets or sets image source url
  6471. */
  6472. set: function (value) {
  6473. var _this = this;
  6474. if (this._source === value) {
  6475. return;
  6476. }
  6477. this._loaded = false;
  6478. this._source = value;
  6479. this._domImage = document.createElement("img");
  6480. this._domImage.onload = function () {
  6481. _this._onImageLoaded();
  6482. };
  6483. if (value) {
  6484. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6485. this._domImage.src = value;
  6486. }
  6487. },
  6488. enumerable: true,
  6489. configurable: true
  6490. });
  6491. Object.defineProperty(Image.prototype, "cellWidth", {
  6492. /**
  6493. * Gets or sets the cell width to use when animation sheet is enabled
  6494. * @see http://doc.babylonjs.com/how_to/gui#image
  6495. */
  6496. get: function () {
  6497. return this._cellWidth;
  6498. },
  6499. set: function (value) {
  6500. if (this._cellWidth === value) {
  6501. return;
  6502. }
  6503. this._cellWidth = value;
  6504. this._markAsDirty();
  6505. },
  6506. enumerable: true,
  6507. configurable: true
  6508. });
  6509. Object.defineProperty(Image.prototype, "cellHeight", {
  6510. /**
  6511. * Gets or sets the cell height to use when animation sheet is enabled
  6512. * @see http://doc.babylonjs.com/how_to/gui#image
  6513. */
  6514. get: function () {
  6515. return this._cellHeight;
  6516. },
  6517. set: function (value) {
  6518. if (this._cellHeight === value) {
  6519. return;
  6520. }
  6521. this._cellHeight = value;
  6522. this._markAsDirty();
  6523. },
  6524. enumerable: true,
  6525. configurable: true
  6526. });
  6527. Object.defineProperty(Image.prototype, "cellId", {
  6528. /**
  6529. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6530. * @see http://doc.babylonjs.com/how_to/gui#image
  6531. */
  6532. get: function () {
  6533. return this._cellId;
  6534. },
  6535. set: function (value) {
  6536. if (this._cellId === value) {
  6537. return;
  6538. }
  6539. this._cellId = value;
  6540. this._markAsDirty();
  6541. },
  6542. enumerable: true,
  6543. configurable: true
  6544. });
  6545. /**
  6546. * Tests if a given coordinates belong to the current control
  6547. * @param x defines x coordinate to test
  6548. * @param y defines y coordinate to test
  6549. * @returns true if the coordinates are inside the control
  6550. */
  6551. Image.prototype.contains = function (x, y) {
  6552. if (!_super.prototype.contains.call(this, x, y)) {
  6553. return false;
  6554. }
  6555. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6556. return true;
  6557. }
  6558. var canvas = Image._WorkingCanvas;
  6559. var context = canvas.getContext("2d");
  6560. var width = this._currentMeasure.width | 0;
  6561. var height = this._currentMeasure.height | 0;
  6562. var imageData = context.getImageData(0, 0, width, height).data;
  6563. x = (x - this._currentMeasure.left) | 0;
  6564. y = (y - this._currentMeasure.top) | 0;
  6565. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6566. return pickedPixel > 0;
  6567. };
  6568. Image.prototype._getTypeName = function () {
  6569. return "Image";
  6570. };
  6571. /** Force the control to synchronize with its content */
  6572. Image.prototype.synchronizeSizeWithContent = function () {
  6573. if (!this._loaded) {
  6574. return;
  6575. }
  6576. this.width = this._domImage.width + "px";
  6577. this.height = this._domImage.height + "px";
  6578. };
  6579. Image.prototype._processMeasures = function (parentMeasure, context) {
  6580. if (this._loaded) {
  6581. switch (this._stretch) {
  6582. case Image.STRETCH_NONE:
  6583. break;
  6584. case Image.STRETCH_FILL:
  6585. break;
  6586. case Image.STRETCH_UNIFORM:
  6587. break;
  6588. case Image.STRETCH_NINE_PATCH:
  6589. break;
  6590. case Image.STRETCH_EXTEND:
  6591. if (this._autoScale) {
  6592. this.synchronizeSizeWithContent();
  6593. }
  6594. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6595. this.parent.adaptWidthToChildren = true;
  6596. this.parent.adaptHeightToChildren = true;
  6597. }
  6598. break;
  6599. }
  6600. }
  6601. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6602. };
  6603. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6604. if (!this._detectPointerOnOpaqueOnly) {
  6605. return;
  6606. }
  6607. if (!Image._WorkingCanvas) {
  6608. Image._WorkingCanvas = document.createElement('canvas');
  6609. }
  6610. var canvas = Image._WorkingCanvas;
  6611. var width = this._currentMeasure.width;
  6612. var height = this._currentMeasure.height;
  6613. var context = canvas.getContext("2d");
  6614. canvas.width = width;
  6615. canvas.height = height;
  6616. context.clearRect(0, 0, width, height);
  6617. };
  6618. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6619. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6620. if (!this._detectPointerOnOpaqueOnly) {
  6621. return;
  6622. }
  6623. var canvas = Image._WorkingCanvas;
  6624. context = canvas.getContext("2d");
  6625. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6626. };
  6627. Image.prototype._draw = function (context) {
  6628. context.save();
  6629. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6630. context.shadowColor = this.shadowColor;
  6631. context.shadowBlur = this.shadowBlur;
  6632. context.shadowOffsetX = this.shadowOffsetX;
  6633. context.shadowOffsetY = this.shadowOffsetY;
  6634. }
  6635. var x, y, width, height;
  6636. if (this.cellId == -1) {
  6637. x = this._sourceLeft;
  6638. y = this._sourceTop;
  6639. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6640. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6641. }
  6642. else {
  6643. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6644. var column = (this.cellId / rowCount) >> 0;
  6645. var row = this.cellId % rowCount;
  6646. x = this.cellWidth * row;
  6647. y = this.cellHeight * column;
  6648. width = this.cellWidth;
  6649. height = this.cellHeight;
  6650. }
  6651. this._prepareWorkingCanvasForOpaqueDetection();
  6652. this._applyStates(context);
  6653. if (this._loaded) {
  6654. switch (this._stretch) {
  6655. case Image.STRETCH_NONE:
  6656. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6657. break;
  6658. case Image.STRETCH_FILL:
  6659. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6660. break;
  6661. case Image.STRETCH_UNIFORM:
  6662. var hRatio = this._currentMeasure.width / width;
  6663. var vRatio = this._currentMeasure.height / height;
  6664. var ratio = Math.min(hRatio, vRatio);
  6665. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6666. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6667. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6668. break;
  6669. case Image.STRETCH_EXTEND:
  6670. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6671. break;
  6672. case Image.STRETCH_NINE_PATCH:
  6673. this._renderNinePatch(context);
  6674. break;
  6675. }
  6676. }
  6677. context.restore();
  6678. };
  6679. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6680. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6681. };
  6682. Image.prototype._renderNinePatch = function (context) {
  6683. var height = this._imageHeight;
  6684. var leftWidth = this._sliceLeft;
  6685. var topHeight = this._sliceTop;
  6686. var bottomHeight = this._imageHeight - this._sliceBottom;
  6687. var rightWidth = this._imageWidth - this._sliceRight;
  6688. var left = 0;
  6689. var top = 0;
  6690. if (this._populateNinePatchSlicesFromImage) {
  6691. left = 1;
  6692. top = 1;
  6693. height -= 2;
  6694. leftWidth -= 1;
  6695. topHeight -= 1;
  6696. bottomHeight -= 1;
  6697. rightWidth -= 1;
  6698. }
  6699. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6700. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6701. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6702. // Corners
  6703. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6704. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6705. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6706. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6707. // Center
  6708. 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);
  6709. // Borders
  6710. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6711. 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);
  6712. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6713. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6714. };
  6715. Image.prototype.dispose = function () {
  6716. _super.prototype.dispose.call(this);
  6717. this.onImageLoadedObservable.clear();
  6718. };
  6719. Image._WorkingCanvas = null;
  6720. // Static
  6721. /** STRETCH_NONE */
  6722. Image.STRETCH_NONE = 0;
  6723. /** STRETCH_FILL */
  6724. Image.STRETCH_FILL = 1;
  6725. /** STRETCH_UNIFORM */
  6726. Image.STRETCH_UNIFORM = 2;
  6727. /** STRETCH_EXTEND */
  6728. Image.STRETCH_EXTEND = 3;
  6729. /** NINE_PATCH */
  6730. Image.STRETCH_NINE_PATCH = 4;
  6731. return Image;
  6732. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6733. /***/ }),
  6734. /***/ "./2D/controls/index.ts":
  6735. /*!******************************!*\
  6736. !*** ./2D/controls/index.ts ***!
  6737. \******************************/
  6738. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, name */
  6739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6740. "use strict";
  6741. __webpack_require__.r(__webpack_exports__);
  6742. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6744. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6746. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6748. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6750. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6752. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6754. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6756. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6758. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6760. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6762. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6764. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6766. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6768. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6770. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6776. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6778. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6781. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6784. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6786. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6788. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6790. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6792. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6794. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6796. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6798. /***/ }),
  6799. /***/ "./2D/controls/inputPassword.ts":
  6800. /*!**************************************!*\
  6801. !*** ./2D/controls/inputPassword.ts ***!
  6802. \**************************************/
  6803. /*! exports provided: InputPassword */
  6804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6805. "use strict";
  6806. __webpack_require__.r(__webpack_exports__);
  6807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6808. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6809. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6810. /**
  6811. * Class used to create a password control
  6812. */
  6813. var InputPassword = /** @class */ (function (_super) {
  6814. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6815. function InputPassword() {
  6816. return _super !== null && _super.apply(this, arguments) || this;
  6817. }
  6818. InputPassword.prototype._beforeRenderText = function (text) {
  6819. var txt = "";
  6820. for (var i = 0; i < text.length; i++) {
  6821. txt += "\u2022";
  6822. }
  6823. return txt;
  6824. };
  6825. return InputPassword;
  6826. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6827. /***/ }),
  6828. /***/ "./2D/controls/inputText.ts":
  6829. /*!**********************************!*\
  6830. !*** ./2D/controls/inputText.ts ***!
  6831. \**********************************/
  6832. /*! exports provided: InputText */
  6833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6834. "use strict";
  6835. __webpack_require__.r(__webpack_exports__);
  6836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6837. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6838. <<<<<<< HEAD
  6839. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6840. =======
  6841. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  6842. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  6843. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6844. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6845. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6846. /**
  6847. * Class used to create input text control
  6848. */
  6849. var InputText = /** @class */ (function (_super) {
  6850. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6851. /**
  6852. * Creates a new InputText
  6853. * @param name defines the control name
  6854. * @param text defines the text of the control
  6855. */
  6856. function InputText(name, text) {
  6857. if (text === void 0) { text = ""; }
  6858. var _this = _super.call(this, name) || this;
  6859. _this.name = name;
  6860. _this._text = "";
  6861. _this._placeholderText = "";
  6862. _this._background = "#222222";
  6863. _this._focusedBackground = "#000000";
  6864. _this._focusedColor = "white";
  6865. _this._placeholderColor = "gray";
  6866. _this._thickness = 1;
  6867. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6868. _this._autoStretchWidth = true;
  6869. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6870. _this._isFocused = false;
  6871. _this._blinkIsEven = false;
  6872. _this._cursorOffset = 0;
  6873. _this._deadKey = false;
  6874. _this._addKey = true;
  6875. _this._currentKey = "";
  6876. _this._isTextHighlightOn = false;
  6877. _this._textHighlightColor = "#d5e0ff";
  6878. _this._highligherOpacity = 0.4;
  6879. _this._highlightedText = "";
  6880. _this._startHighlightIndex = 0;
  6881. _this._endHighlightIndex = 0;
  6882. _this._cursorIndex = -1;
  6883. _this._onFocusSelectAll = false;
  6884. _this._isPointerDown = false;
  6885. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6886. _this.promptMessage = "Please enter text:";
  6887. /** Observable raised when the text changes */
  6888. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6889. /** Observable raised just before an entered character is to be added */
  6890. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6891. /** Observable raised when the control gets the focus */
  6892. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6893. /** Observable raised when the control loses the focus */
  6894. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6895. /**Observable raised when the text is highlighted */
  6896. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6897. /**Observable raised when copy event is triggered */
  6898. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6899. /** Observable raised when cut event is triggered */
  6900. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6901. /** Observable raised when paste event is triggered */
  6902. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6903. /** Observable raised when a key event was processed */
  6904. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6905. _this.text = text;
  6906. _this.isPointerBlocker = true;
  6907. return _this;
  6908. }
  6909. Object.defineProperty(InputText.prototype, "maxWidth", {
  6910. /** Gets or sets the maximum width allowed by the control */
  6911. get: function () {
  6912. return this._maxWidth.toString(this._host);
  6913. },
  6914. set: function (value) {
  6915. if (this._maxWidth.toString(this._host) === value) {
  6916. return;
  6917. }
  6918. if (this._maxWidth.fromString(value)) {
  6919. this._markAsDirty();
  6920. }
  6921. },
  6922. enumerable: true,
  6923. configurable: true
  6924. });
  6925. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6926. /** Gets the maximum width allowed by the control in pixels */
  6927. get: function () {
  6928. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6929. },
  6930. enumerable: true,
  6931. configurable: true
  6932. });
  6933. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6934. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6935. get: function () {
  6936. return this._highligherOpacity;
  6937. },
  6938. set: function (value) {
  6939. if (this._highligherOpacity === value) {
  6940. return;
  6941. }
  6942. this._highligherOpacity = value;
  6943. this._markAsDirty();
  6944. },
  6945. enumerable: true,
  6946. configurable: true
  6947. });
  6948. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6949. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6950. get: function () {
  6951. return this._onFocusSelectAll;
  6952. },
  6953. set: function (value) {
  6954. if (this._onFocusSelectAll === value) {
  6955. return;
  6956. }
  6957. this._onFocusSelectAll = value;
  6958. this._markAsDirty();
  6959. },
  6960. enumerable: true,
  6961. configurable: true
  6962. });
  6963. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6964. /** Gets or sets the text hightlight color */
  6965. get: function () {
  6966. return this._textHighlightColor;
  6967. },
  6968. set: function (value) {
  6969. if (this._textHighlightColor === value) {
  6970. return;
  6971. }
  6972. this._textHighlightColor = value;
  6973. this._markAsDirty();
  6974. },
  6975. enumerable: true,
  6976. configurable: true
  6977. });
  6978. Object.defineProperty(InputText.prototype, "margin", {
  6979. /** Gets or sets control margin */
  6980. get: function () {
  6981. return this._margin.toString(this._host);
  6982. },
  6983. set: function (value) {
  6984. if (this._margin.toString(this._host) === value) {
  6985. return;
  6986. }
  6987. if (this._margin.fromString(value)) {
  6988. this._markAsDirty();
  6989. }
  6990. },
  6991. enumerable: true,
  6992. configurable: true
  6993. });
  6994. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6995. /** Gets control margin in pixels */
  6996. get: function () {
  6997. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6998. },
  6999. enumerable: true,
  7000. configurable: true
  7001. });
  7002. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7003. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7004. get: function () {
  7005. return this._autoStretchWidth;
  7006. },
  7007. set: function (value) {
  7008. if (this._autoStretchWidth === value) {
  7009. return;
  7010. }
  7011. this._autoStretchWidth = value;
  7012. this._markAsDirty();
  7013. },
  7014. enumerable: true,
  7015. configurable: true
  7016. });
  7017. Object.defineProperty(InputText.prototype, "thickness", {
  7018. /** Gets or sets border thickness */
  7019. get: function () {
  7020. return this._thickness;
  7021. },
  7022. set: function (value) {
  7023. if (this._thickness === value) {
  7024. return;
  7025. }
  7026. this._thickness = value;
  7027. this._markAsDirty();
  7028. },
  7029. enumerable: true,
  7030. configurable: true
  7031. });
  7032. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7033. /** Gets or sets the background color when focused */
  7034. get: function () {
  7035. return this._focusedBackground;
  7036. },
  7037. set: function (value) {
  7038. if (this._focusedBackground === value) {
  7039. return;
  7040. }
  7041. this._focusedBackground = value;
  7042. this._markAsDirty();
  7043. },
  7044. enumerable: true,
  7045. configurable: true
  7046. });
  7047. Object.defineProperty(InputText.prototype, "focusedColor", {
  7048. /** Gets or sets the background color when focused */
  7049. get: function () {
  7050. return this._focusedColor;
  7051. },
  7052. set: function (value) {
  7053. if (this._focusedColor === value) {
  7054. return;
  7055. }
  7056. this._focusedColor = value;
  7057. this._markAsDirty();
  7058. },
  7059. enumerable: true,
  7060. configurable: true
  7061. });
  7062. Object.defineProperty(InputText.prototype, "background", {
  7063. /** Gets or sets the background color */
  7064. get: function () {
  7065. return this._background;
  7066. },
  7067. set: function (value) {
  7068. if (this._background === value) {
  7069. return;
  7070. }
  7071. this._background = value;
  7072. this._markAsDirty();
  7073. },
  7074. enumerable: true,
  7075. configurable: true
  7076. });
  7077. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7078. /** Gets or sets the placeholder color */
  7079. get: function () {
  7080. return this._placeholderColor;
  7081. },
  7082. set: function (value) {
  7083. if (this._placeholderColor === value) {
  7084. return;
  7085. }
  7086. this._placeholderColor = value;
  7087. this._markAsDirty();
  7088. },
  7089. enumerable: true,
  7090. configurable: true
  7091. });
  7092. Object.defineProperty(InputText.prototype, "placeholderText", {
  7093. /** Gets or sets the text displayed when the control is empty */
  7094. get: function () {
  7095. return this._placeholderText;
  7096. },
  7097. set: function (value) {
  7098. if (this._placeholderText === value) {
  7099. return;
  7100. }
  7101. this._placeholderText = value;
  7102. this._markAsDirty();
  7103. },
  7104. enumerable: true,
  7105. configurable: true
  7106. });
  7107. Object.defineProperty(InputText.prototype, "deadKey", {
  7108. /** Gets or sets the dead key flag */
  7109. get: function () {
  7110. return this._deadKey;
  7111. },
  7112. set: function (flag) {
  7113. this._deadKey = flag;
  7114. },
  7115. enumerable: true,
  7116. configurable: true
  7117. });
  7118. Object.defineProperty(InputText.prototype, "highlightedText", {
  7119. /** Gets or sets the highlight text */
  7120. get: function () {
  7121. return this._highlightedText;
  7122. },
  7123. set: function (text) {
  7124. if (this._highlightedText === text) {
  7125. return;
  7126. }
  7127. this._highlightedText = text;
  7128. this._markAsDirty();
  7129. },
  7130. enumerable: true,
  7131. configurable: true
  7132. });
  7133. Object.defineProperty(InputText.prototype, "addKey", {
  7134. /** Gets or sets if the current key should be added */
  7135. get: function () {
  7136. return this._addKey;
  7137. },
  7138. set: function (flag) {
  7139. this._addKey = flag;
  7140. },
  7141. enumerable: true,
  7142. configurable: true
  7143. });
  7144. Object.defineProperty(InputText.prototype, "currentKey", {
  7145. /** Gets or sets the value of the current key being entered */
  7146. get: function () {
  7147. return this._currentKey;
  7148. },
  7149. set: function (key) {
  7150. this._currentKey = key;
  7151. },
  7152. enumerable: true,
  7153. configurable: true
  7154. });
  7155. Object.defineProperty(InputText.prototype, "text", {
  7156. /** Gets or sets the text displayed in the control */
  7157. get: function () {
  7158. return this._text;
  7159. },
  7160. set: function (value) {
  7161. var valueAsString = value.toString(); // Forcing convertion
  7162. if (this._text === valueAsString) {
  7163. return;
  7164. }
  7165. this._text = valueAsString;
  7166. this._markAsDirty();
  7167. this.onTextChangedObservable.notifyObservers(this);
  7168. },
  7169. enumerable: true,
  7170. configurable: true
  7171. });
  7172. Object.defineProperty(InputText.prototype, "width", {
  7173. /** Gets or sets control width */
  7174. get: function () {
  7175. return this._width.toString(this._host);
  7176. },
  7177. set: function (value) {
  7178. if (this._width.toString(this._host) === value) {
  7179. return;
  7180. }
  7181. if (this._width.fromString(value)) {
  7182. this._markAsDirty();
  7183. }
  7184. this.autoStretchWidth = false;
  7185. },
  7186. enumerable: true,
  7187. configurable: true
  7188. });
  7189. /** @hidden */
  7190. InputText.prototype.onBlur = function () {
  7191. this._isFocused = false;
  7192. this._scrollLeft = null;
  7193. this._cursorOffset = 0;
  7194. clearTimeout(this._blinkTimeout);
  7195. this._markAsDirty();
  7196. this.onBlurObservable.notifyObservers(this);
  7197. this._host.unRegisterClipboardEvents();
  7198. if (this._onClipboardObserver) {
  7199. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7200. }
  7201. var scene = this._host.getScene();
  7202. if (this._onPointerDblTapObserver && scene) {
  7203. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7204. }
  7205. };
  7206. /** @hidden */
  7207. InputText.prototype.onFocus = function () {
  7208. var _this = this;
  7209. if (!this._isEnabled) {
  7210. return;
  7211. }
  7212. this._scrollLeft = null;
  7213. this._isFocused = true;
  7214. this._blinkIsEven = false;
  7215. this._cursorOffset = 0;
  7216. this._markAsDirty();
  7217. this.onFocusObservable.notifyObservers(this);
  7218. if (navigator.userAgent.indexOf("Mobile") !== -1) {
  7219. var value = prompt(this.promptMessage);
  7220. if (value !== null) {
  7221. this.text = value;
  7222. }
  7223. this._host.focusedControl = null;
  7224. return;
  7225. }
  7226. this._host.registerClipboardEvents();
  7227. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7228. // process clipboard event, can be configured.
  7229. switch (clipboardInfo.type) {
  7230. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7231. _this._onCopyText(clipboardInfo.event);
  7232. _this.onTextCopyObservable.notifyObservers(_this);
  7233. break;
  7234. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7235. _this._onCutText(clipboardInfo.event);
  7236. _this.onTextCutObservable.notifyObservers(_this);
  7237. break;
  7238. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7239. _this._onPasteText(clipboardInfo.event);
  7240. _this.onTextPasteObservable.notifyObservers(_this);
  7241. break;
  7242. default: return;
  7243. }
  7244. });
  7245. var scene = this._host.getScene();
  7246. if (scene) {
  7247. //register the pointer double tap event
  7248. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7249. if (!_this._isFocused) {
  7250. return;
  7251. }
  7252. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7253. _this._processDblClick(pointerInfo);
  7254. }
  7255. });
  7256. }
  7257. if (this._onFocusSelectAll) {
  7258. this._selectAllText();
  7259. }
  7260. };
  7261. InputText.prototype._getTypeName = function () {
  7262. return "InputText";
  7263. };
  7264. /**
  7265. * Function called to get the list of controls that should not steal the focus from this control
  7266. * @returns an array of controls
  7267. */
  7268. InputText.prototype.keepsFocusWith = function () {
  7269. if (!this._connectedVirtualKeyboard) {
  7270. return null;
  7271. }
  7272. return [this._connectedVirtualKeyboard];
  7273. };
  7274. /** @hidden */
  7275. InputText.prototype.processKey = function (keyCode, key, evt) {
  7276. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7277. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7278. return;
  7279. }
  7280. //select all
  7281. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7282. this._selectAllText();
  7283. evt.preventDefault();
  7284. return;
  7285. }
  7286. // Specific cases
  7287. switch (keyCode) {
  7288. case 32: //SPACE
  7289. key = " "; //ie11 key for space is "Spacebar"
  7290. break;
  7291. case 191: //SLASH
  7292. if (evt) {
  7293. evt.preventDefault();
  7294. }
  7295. break;
  7296. case 8: // BACKSPACE
  7297. if (this._text && this._text.length > 0) {
  7298. //delete the highlighted text
  7299. if (this._isTextHighlightOn) {
  7300. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7301. this._isTextHighlightOn = false;
  7302. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7303. this._blinkIsEven = false;
  7304. if (evt) {
  7305. evt.preventDefault();
  7306. }
  7307. return;
  7308. }
  7309. //delete single character
  7310. if (this._cursorOffset === 0) {
  7311. this.text = this._text.substr(0, this._text.length - 1);
  7312. }
  7313. else {
  7314. var deletePosition = this._text.length - this._cursorOffset;
  7315. if (deletePosition > 0) {
  7316. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7317. }
  7318. }
  7319. }
  7320. if (evt) {
  7321. evt.preventDefault();
  7322. }
  7323. return;
  7324. case 46: // DELETE
  7325. if (this._isTextHighlightOn) {
  7326. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7327. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7328. while (decrementor > 0 && this._cursorOffset > 0) {
  7329. this._cursorOffset--;
  7330. }
  7331. this._isTextHighlightOn = false;
  7332. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7333. if (evt) {
  7334. evt.preventDefault();
  7335. }
  7336. return;
  7337. }
  7338. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7339. var deletePosition = this._text.length - this._cursorOffset;
  7340. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7341. this._cursorOffset--;
  7342. }
  7343. if (evt) {
  7344. evt.preventDefault();
  7345. }
  7346. return;
  7347. case 13: // RETURN
  7348. this._host.focusedControl = null;
  7349. this._isTextHighlightOn = false;
  7350. return;
  7351. case 35: // END
  7352. this._cursorOffset = 0;
  7353. this._blinkIsEven = false;
  7354. this._isTextHighlightOn = false;
  7355. this._markAsDirty();
  7356. return;
  7357. case 36: // HOME
  7358. this._cursorOffset = this._text.length;
  7359. this._blinkIsEven = false;
  7360. this._isTextHighlightOn = false;
  7361. this._markAsDirty();
  7362. return;
  7363. case 37: // LEFT
  7364. this._cursorOffset++;
  7365. if (this._cursorOffset > this._text.length) {
  7366. this._cursorOffset = this._text.length;
  7367. }
  7368. if (evt && evt.shiftKey) {
  7369. // update the cursor
  7370. this._blinkIsEven = false;
  7371. // shift + ctrl/cmd + <-
  7372. if (evt.ctrlKey || evt.metaKey) {
  7373. if (!this._isTextHighlightOn) {
  7374. if (this._text.length === this._cursorOffset) {
  7375. return;
  7376. }
  7377. else {
  7378. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7379. }
  7380. }
  7381. this._startHighlightIndex = 0;
  7382. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7383. this._cursorOffset = this._text.length;
  7384. this._isTextHighlightOn = true;
  7385. this._markAsDirty();
  7386. return;
  7387. }
  7388. //store the starting point
  7389. if (!this._isTextHighlightOn) {
  7390. this._isTextHighlightOn = true;
  7391. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7392. }
  7393. //if text is already highlighted
  7394. else if (this._cursorIndex === -1) {
  7395. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7396. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7397. }
  7398. //set the highlight indexes
  7399. if (this._cursorIndex < this._cursorOffset) {
  7400. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7401. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7402. }
  7403. else if (this._cursorIndex > this._cursorOffset) {
  7404. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7405. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7406. }
  7407. else {
  7408. this._isTextHighlightOn = false;
  7409. }
  7410. this._markAsDirty();
  7411. return;
  7412. }
  7413. if (this._isTextHighlightOn) {
  7414. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7415. this._isTextHighlightOn = false;
  7416. }
  7417. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7418. this._cursorOffset = this.text.length;
  7419. evt.preventDefault();
  7420. }
  7421. this._blinkIsEven = false;
  7422. this._isTextHighlightOn = false;
  7423. this._cursorIndex = -1;
  7424. this._markAsDirty();
  7425. return;
  7426. case 39: // RIGHT
  7427. this._cursorOffset--;
  7428. if (this._cursorOffset < 0) {
  7429. this._cursorOffset = 0;
  7430. }
  7431. if (evt && evt.shiftKey) {
  7432. //update the cursor
  7433. this._blinkIsEven = false;
  7434. //shift + ctrl/cmd + ->
  7435. if (evt.ctrlKey || evt.metaKey) {
  7436. if (!this._isTextHighlightOn) {
  7437. if (this._cursorOffset === 0) {
  7438. return;
  7439. }
  7440. else {
  7441. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7442. }
  7443. }
  7444. this._endHighlightIndex = this._text.length;
  7445. this._isTextHighlightOn = true;
  7446. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7447. this._cursorOffset = 0;
  7448. this._markAsDirty();
  7449. return;
  7450. }
  7451. if (!this._isTextHighlightOn) {
  7452. this._isTextHighlightOn = true;
  7453. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7454. }
  7455. //if text is already highlighted
  7456. else if (this._cursorIndex === -1) {
  7457. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7458. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7459. }
  7460. //set the highlight indexes
  7461. if (this._cursorIndex < this._cursorOffset) {
  7462. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7463. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7464. }
  7465. else if (this._cursorIndex > this._cursorOffset) {
  7466. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7467. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7468. }
  7469. else {
  7470. this._isTextHighlightOn = false;
  7471. }
  7472. this._markAsDirty();
  7473. return;
  7474. }
  7475. if (this._isTextHighlightOn) {
  7476. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7477. this._isTextHighlightOn = false;
  7478. }
  7479. //ctr + ->
  7480. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7481. this._cursorOffset = 0;
  7482. evt.preventDefault();
  7483. }
  7484. this._blinkIsEven = false;
  7485. this._isTextHighlightOn = false;
  7486. this._cursorIndex = -1;
  7487. this._markAsDirty();
  7488. return;
  7489. case 222: // Dead
  7490. if (evt) {
  7491. evt.preventDefault();
  7492. }
  7493. this._cursorIndex = -1;
  7494. this.deadKey = true;
  7495. break;
  7496. }
  7497. // Printable characters
  7498. if (key &&
  7499. ((keyCode === -1) || // Direct access
  7500. (keyCode === 32) || // Space
  7501. (keyCode > 47 && keyCode < 64) || // Numbers
  7502. (keyCode > 64 && keyCode < 91) || // Letters
  7503. (keyCode > 159 && keyCode < 193) || // Special characters
  7504. (keyCode > 218 && keyCode < 223) || // Special characters
  7505. (keyCode > 95 && keyCode < 112))) { // Numpad
  7506. this._currentKey = key;
  7507. this.onBeforeKeyAddObservable.notifyObservers(this);
  7508. key = this._currentKey;
  7509. if (this._addKey) {
  7510. if (this._isTextHighlightOn) {
  7511. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7512. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7513. this._isTextHighlightOn = false;
  7514. this._blinkIsEven = false;
  7515. this._markAsDirty();
  7516. }
  7517. else if (this._cursorOffset === 0) {
  7518. this.text += key;
  7519. }
  7520. else {
  7521. var insertPosition = this._text.length - this._cursorOffset;
  7522. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7523. }
  7524. }
  7525. }
  7526. };
  7527. /** @hidden */
  7528. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7529. //update the cursor
  7530. this._blinkIsEven = false;
  7531. if (this._cursorIndex === -1) {
  7532. this._cursorIndex = offset;
  7533. }
  7534. else {
  7535. if (this._cursorIndex < this._cursorOffset) {
  7536. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7537. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7538. }
  7539. else if (this._cursorIndex > this._cursorOffset) {
  7540. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7541. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7542. }
  7543. else {
  7544. this._isTextHighlightOn = false;
  7545. this._markAsDirty();
  7546. return;
  7547. }
  7548. }
  7549. this._isTextHighlightOn = true;
  7550. this._markAsDirty();
  7551. };
  7552. /** @hidden */
  7553. InputText.prototype._processDblClick = function (evt) {
  7554. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7555. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7556. this._endHighlightIndex = this._startHighlightIndex;
  7557. var rWord = /\w+/g, moveLeft, moveRight;
  7558. do {
  7559. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7560. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7561. } while (moveLeft || moveRight);
  7562. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7563. this.onTextHighlightObservable.notifyObservers(this);
  7564. this._isTextHighlightOn = true;
  7565. this._clickedCoordinate = null;
  7566. this._blinkIsEven = true;
  7567. this._cursorIndex = -1;
  7568. this._markAsDirty();
  7569. };
  7570. /** @hidden */
  7571. InputText.prototype._selectAllText = function () {
  7572. this._blinkIsEven = true;
  7573. this._isTextHighlightOn = true;
  7574. this._startHighlightIndex = 0;
  7575. this._endHighlightIndex = this._text.length;
  7576. this._cursorOffset = this._text.length;
  7577. this._cursorIndex = -1;
  7578. this._markAsDirty();
  7579. };
  7580. /**
  7581. * Handles the keyboard event
  7582. * @param evt Defines the KeyboardEvent
  7583. */
  7584. InputText.prototype.processKeyboard = function (evt) {
  7585. // process pressed key
  7586. this.processKey(evt.keyCode, evt.key, evt);
  7587. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7588. };
  7589. /** @hidden */
  7590. InputText.prototype._onCopyText = function (ev) {
  7591. this._isTextHighlightOn = false;
  7592. //when write permission to clipbaord data is denied
  7593. try {
  7594. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7595. }
  7596. catch (_a) { } //pass
  7597. this._host.clipboardData = this._highlightedText;
  7598. };
  7599. /** @hidden */
  7600. InputText.prototype._onCutText = function (ev) {
  7601. if (!this._highlightedText) {
  7602. return;
  7603. }
  7604. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7605. this._isTextHighlightOn = false;
  7606. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7607. //when write permission to clipbaord data is denied
  7608. try {
  7609. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7610. }
  7611. catch (_a) { } //pass
  7612. this._host.clipboardData = this._highlightedText;
  7613. this._highlightedText = "";
  7614. };
  7615. /** @hidden */
  7616. InputText.prototype._onPasteText = function (ev) {
  7617. var data = "";
  7618. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7619. data = ev.clipboardData.getData("text/plain");
  7620. }
  7621. else {
  7622. //get the cached data; returns blank string by default
  7623. data = this._host.clipboardData;
  7624. }
  7625. var insertPosition = this._text.length - this._cursorOffset;
  7626. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7627. };
  7628. InputText.prototype._draw = function (context) {
  7629. var _this = this;
  7630. context.save();
  7631. this._applyStates(context);
  7632. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7633. context.shadowColor = this.shadowColor;
  7634. context.shadowBlur = this.shadowBlur;
  7635. context.shadowOffsetX = this.shadowOffsetX;
  7636. context.shadowOffsetY = this.shadowOffsetY;
  7637. }
  7638. // Background
  7639. if (this._isFocused) {
  7640. if (this._focusedBackground) {
  7641. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7642. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7643. }
  7644. }
  7645. else if (this._background) {
  7646. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7647. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7648. }
  7649. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7650. context.shadowBlur = 0;
  7651. context.shadowOffsetX = 0;
  7652. context.shadowOffsetY = 0;
  7653. }
  7654. if (!this._fontOffset) {
  7655. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7656. }
  7657. // Text
  7658. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7659. if (this.color) {
  7660. context.fillStyle = this.color;
  7661. }
  7662. var text = this._beforeRenderText(this._text);
  7663. if (!this._isFocused && !this._text && this._placeholderText) {
  7664. text = this._placeholderText;
  7665. if (this._placeholderColor) {
  7666. context.fillStyle = this._placeholderColor;
  7667. }
  7668. }
  7669. this._textWidth = context.measureText(text).width;
  7670. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7671. if (this._autoStretchWidth) {
  7672. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7673. }
  7674. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7675. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7676. context.save();
  7677. context.beginPath();
  7678. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7679. context.clip();
  7680. if (this._isFocused && this._textWidth > availableWidth) {
  7681. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7682. if (!this._scrollLeft) {
  7683. this._scrollLeft = textLeft;
  7684. }
  7685. }
  7686. else {
  7687. this._scrollLeft = clipTextLeft;
  7688. }
  7689. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7690. // Cursor
  7691. if (this._isFocused) {
  7692. // Need to move cursor
  7693. if (this._clickedCoordinate) {
  7694. var rightPosition = this._scrollLeft + this._textWidth;
  7695. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7696. var currentSize = 0;
  7697. this._cursorOffset = 0;
  7698. var previousDist = 0;
  7699. do {
  7700. if (this._cursorOffset) {
  7701. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7702. }
  7703. this._cursorOffset++;
  7704. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7705. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7706. // Find closest move
  7707. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7708. this._cursorOffset--;
  7709. }
  7710. this._blinkIsEven = false;
  7711. this._clickedCoordinate = null;
  7712. }
  7713. // Render cursor
  7714. if (!this._blinkIsEven) {
  7715. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7716. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7717. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7718. if (cursorLeft < clipTextLeft) {
  7719. this._scrollLeft += (clipTextLeft - cursorLeft);
  7720. cursorLeft = clipTextLeft;
  7721. this._markAsDirty();
  7722. }
  7723. else if (cursorLeft > clipTextLeft + availableWidth) {
  7724. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7725. cursorLeft = clipTextLeft + availableWidth;
  7726. this._markAsDirty();
  7727. }
  7728. if (!this._isTextHighlightOn) {
  7729. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7730. }
  7731. }
  7732. clearTimeout(this._blinkTimeout);
  7733. this._blinkTimeout = setTimeout(function () {
  7734. _this._blinkIsEven = !_this._blinkIsEven;
  7735. _this._markAsDirty();
  7736. }, 500);
  7737. //show the highlighted text
  7738. if (this._isTextHighlightOn) {
  7739. clearTimeout(this._blinkTimeout);
  7740. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7741. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7742. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7743. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7744. if (highlightCursorLeft < clipTextLeft) {
  7745. width = width - (clipTextLeft - highlightCursorLeft);
  7746. if (!width) {
  7747. // when using left arrow on text.length > availableWidth;
  7748. // assigns the width of the first letter after clipTextLeft
  7749. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7750. }
  7751. highlightCursorLeft = clipTextLeft;
  7752. }
  7753. //for transparancy
  7754. context.globalAlpha = this._highligherOpacity;
  7755. context.fillStyle = this._textHighlightColor;
  7756. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7757. context.globalAlpha = 1.0;
  7758. }
  7759. }
  7760. context.restore();
  7761. // Border
  7762. if (this._thickness) {
  7763. if (this._isFocused) {
  7764. if (this.focusedColor) {
  7765. context.strokeStyle = this.focusedColor;
  7766. }
  7767. }
  7768. else {
  7769. if (this.color) {
  7770. context.strokeStyle = this.color;
  7771. }
  7772. }
  7773. context.lineWidth = this._thickness;
  7774. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7775. }
  7776. context.restore();
  7777. };
  7778. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7779. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7780. return false;
  7781. }
  7782. this._clickedCoordinate = coordinates.x;
  7783. this._isTextHighlightOn = false;
  7784. this._highlightedText = "";
  7785. this._cursorIndex = -1;
  7786. this._isPointerDown = true;
  7787. this._host._capturingControl[pointerId] = this;
  7788. if (this._host.focusedControl === this) {
  7789. // Move cursor
  7790. clearTimeout(this._blinkTimeout);
  7791. this._markAsDirty();
  7792. return true;
  7793. }
  7794. if (!this._isEnabled) {
  7795. return false;
  7796. }
  7797. this._host.focusedControl = this;
  7798. return true;
  7799. };
  7800. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7801. if (this._host.focusedControl === this && this._isPointerDown) {
  7802. this._clickedCoordinate = coordinates.x;
  7803. this._markAsDirty();
  7804. this._updateValueFromCursorIndex(this._cursorOffset);
  7805. }
  7806. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7807. };
  7808. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7809. this._isPointerDown = false;
  7810. delete this._host._capturingControl[pointerId];
  7811. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7812. };
  7813. InputText.prototype._beforeRenderText = function (text) {
  7814. return text;
  7815. };
  7816. InputText.prototype.dispose = function () {
  7817. _super.prototype.dispose.call(this);
  7818. this.onBlurObservable.clear();
  7819. this.onFocusObservable.clear();
  7820. this.onTextChangedObservable.clear();
  7821. this.onTextCopyObservable.clear();
  7822. this.onTextCutObservable.clear();
  7823. this.onTextPasteObservable.clear();
  7824. this.onTextHighlightObservable.clear();
  7825. this.onKeyboardEventProcessedObservable.clear();
  7826. };
  7827. return InputText;
  7828. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7829. /***/ }),
  7830. /***/ "./2D/controls/line.ts":
  7831. /*!*****************************!*\
  7832. !*** ./2D/controls/line.ts ***!
  7833. \*****************************/
  7834. /*! exports provided: Line */
  7835. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7836. "use strict";
  7837. __webpack_require__.r(__webpack_exports__);
  7838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7839. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7840. <<<<<<< HEAD
  7841. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  7842. =======
  7843. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  7844. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  7845. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7846. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7847. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7848. /** Class used to render 2D lines */
  7849. var Line = /** @class */ (function (_super) {
  7850. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7851. /**
  7852. * Creates a new Line
  7853. * @param name defines the control name
  7854. */
  7855. function Line(name) {
  7856. var _this = _super.call(this, name) || this;
  7857. _this.name = name;
  7858. _this._lineWidth = 1;
  7859. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7860. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7861. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7862. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7863. _this._dash = new Array();
  7864. _this.isHitTestVisible = false;
  7865. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7866. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7867. return _this;
  7868. }
  7869. Object.defineProperty(Line.prototype, "dash", {
  7870. /** Gets or sets the dash pattern */
  7871. get: function () {
  7872. return this._dash;
  7873. },
  7874. set: function (value) {
  7875. if (this._dash === value) {
  7876. return;
  7877. }
  7878. this._dash = value;
  7879. this._markAsDirty();
  7880. },
  7881. enumerable: true,
  7882. configurable: true
  7883. });
  7884. Object.defineProperty(Line.prototype, "connectedControl", {
  7885. /** Gets or sets the control connected with the line end */
  7886. get: function () {
  7887. return this._connectedControl;
  7888. },
  7889. set: function (value) {
  7890. var _this = this;
  7891. if (this._connectedControl === value) {
  7892. return;
  7893. }
  7894. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7895. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7896. this._connectedControlDirtyObserver = null;
  7897. }
  7898. if (value) {
  7899. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7900. }
  7901. this._connectedControl = value;
  7902. this._markAsDirty();
  7903. },
  7904. enumerable: true,
  7905. configurable: true
  7906. });
  7907. Object.defineProperty(Line.prototype, "x1", {
  7908. /** Gets or sets start coordinates on X axis */
  7909. get: function () {
  7910. return this._x1.toString(this._host);
  7911. },
  7912. set: function (value) {
  7913. if (this._x1.toString(this._host) === value) {
  7914. return;
  7915. }
  7916. if (this._x1.fromString(value)) {
  7917. this._markAsDirty();
  7918. }
  7919. },
  7920. enumerable: true,
  7921. configurable: true
  7922. });
  7923. Object.defineProperty(Line.prototype, "y1", {
  7924. /** Gets or sets start coordinates on Y axis */
  7925. get: function () {
  7926. return this._y1.toString(this._host);
  7927. },
  7928. set: function (value) {
  7929. if (this._y1.toString(this._host) === value) {
  7930. return;
  7931. }
  7932. if (this._y1.fromString(value)) {
  7933. this._markAsDirty();
  7934. }
  7935. },
  7936. enumerable: true,
  7937. configurable: true
  7938. });
  7939. Object.defineProperty(Line.prototype, "x2", {
  7940. /** Gets or sets end coordinates on X axis */
  7941. get: function () {
  7942. return this._x2.toString(this._host);
  7943. },
  7944. set: function (value) {
  7945. if (this._x2.toString(this._host) === value) {
  7946. return;
  7947. }
  7948. if (this._x2.fromString(value)) {
  7949. this._markAsDirty();
  7950. }
  7951. },
  7952. enumerable: true,
  7953. configurable: true
  7954. });
  7955. Object.defineProperty(Line.prototype, "y2", {
  7956. /** Gets or sets end coordinates on Y axis */
  7957. get: function () {
  7958. return this._y2.toString(this._host);
  7959. },
  7960. set: function (value) {
  7961. if (this._y2.toString(this._host) === value) {
  7962. return;
  7963. }
  7964. if (this._y2.fromString(value)) {
  7965. this._markAsDirty();
  7966. }
  7967. },
  7968. enumerable: true,
  7969. configurable: true
  7970. });
  7971. Object.defineProperty(Line.prototype, "lineWidth", {
  7972. /** Gets or sets line width */
  7973. get: function () {
  7974. return this._lineWidth;
  7975. },
  7976. set: function (value) {
  7977. if (this._lineWidth === value) {
  7978. return;
  7979. }
  7980. this._lineWidth = value;
  7981. this._markAsDirty();
  7982. },
  7983. enumerable: true,
  7984. configurable: true
  7985. });
  7986. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7987. /** Gets or sets horizontal alignment */
  7988. set: function (value) {
  7989. return;
  7990. },
  7991. enumerable: true,
  7992. configurable: true
  7993. });
  7994. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7995. /** Gets or sets vertical alignment */
  7996. set: function (value) {
  7997. return;
  7998. },
  7999. enumerable: true,
  8000. configurable: true
  8001. });
  8002. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8003. get: function () {
  8004. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8005. },
  8006. enumerable: true,
  8007. configurable: true
  8008. });
  8009. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8010. get: function () {
  8011. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8012. },
  8013. enumerable: true,
  8014. configurable: true
  8015. });
  8016. Line.prototype._getTypeName = function () {
  8017. return "Line";
  8018. };
  8019. Line.prototype._draw = function (context) {
  8020. context.save();
  8021. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8022. context.shadowColor = this.shadowColor;
  8023. context.shadowBlur = this.shadowBlur;
  8024. context.shadowOffsetX = this.shadowOffsetX;
  8025. context.shadowOffsetY = this.shadowOffsetY;
  8026. }
  8027. this._applyStates(context);
  8028. context.strokeStyle = this.color;
  8029. context.lineWidth = this._lineWidth;
  8030. context.setLineDash(this._dash);
  8031. context.beginPath();
  8032. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.left + this._y1.getValue(this._host));
  8033. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.left + this._effectiveY2);
  8034. context.stroke();
  8035. context.restore();
  8036. };
  8037. Line.prototype._measure = function () {
  8038. // Width / Height
  8039. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8040. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8041. };
  8042. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8043. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8044. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8045. };
  8046. /**
  8047. * Move one end of the line given 3D cartesian coordinates.
  8048. * @param position Targeted world position
  8049. * @param scene Scene
  8050. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8051. */
  8052. Line.prototype.moveToVector3 = function (position, scene, end) {
  8053. if (end === void 0) { end = false; }
  8054. if (!this._host || this.parent !== this._host._rootContainer) {
  8055. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8056. return;
  8057. }
  8058. var globalViewport = this._host._getGlobalViewport(scene);
  8059. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8060. this._moveToProjectedPosition(projectedPosition, end);
  8061. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8062. this.notRenderable = true;
  8063. return;
  8064. }
  8065. this.notRenderable = false;
  8066. };
  8067. /**
  8068. * Move one end of the line to a position in screen absolute space.
  8069. * @param projectedPosition Position in screen absolute space (X, Y)
  8070. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8071. */
  8072. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8073. if (end === void 0) { end = false; }
  8074. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8075. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8076. if (end) {
  8077. this.x2 = x;
  8078. this.y2 = y;
  8079. this._x2.ignoreAdaptiveScaling = true;
  8080. this._y2.ignoreAdaptiveScaling = true;
  8081. }
  8082. else {
  8083. this.x1 = x;
  8084. this.y1 = y;
  8085. this._x1.ignoreAdaptiveScaling = true;
  8086. this._y1.ignoreAdaptiveScaling = true;
  8087. }
  8088. };
  8089. return Line;
  8090. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8091. /***/ }),
  8092. /***/ "./2D/controls/multiLine.ts":
  8093. /*!**********************************!*\
  8094. !*** ./2D/controls/multiLine.ts ***!
  8095. \**********************************/
  8096. /*! exports provided: MultiLine */
  8097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8098. "use strict";
  8099. __webpack_require__.r(__webpack_exports__);
  8100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8101. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8102. <<<<<<< HEAD
  8103. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/observable");
  8104. =======
  8105. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/tools");
  8106. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  8107. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8108. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8109. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8110. /**
  8111. * Class used to create multi line control
  8112. */
  8113. var MultiLine = /** @class */ (function (_super) {
  8114. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8115. /**
  8116. * Creates a new MultiLine
  8117. * @param name defines the control name
  8118. */
  8119. function MultiLine(name) {
  8120. var _this = _super.call(this, name) || this;
  8121. _this.name = name;
  8122. _this._lineWidth = 1;
  8123. /** Function called when a point is updated */
  8124. _this.onPointUpdate = function () {
  8125. _this._markAsDirty();
  8126. };
  8127. _this.isHitTestVisible = false;
  8128. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8129. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8130. _this._dash = [];
  8131. _this._points = [];
  8132. return _this;
  8133. }
  8134. Object.defineProperty(MultiLine.prototype, "dash", {
  8135. /** Gets or sets dash pattern */
  8136. get: function () {
  8137. return this._dash;
  8138. },
  8139. set: function (value) {
  8140. if (this._dash === value) {
  8141. return;
  8142. }
  8143. this._dash = value;
  8144. this._markAsDirty();
  8145. },
  8146. enumerable: true,
  8147. configurable: true
  8148. });
  8149. /**
  8150. * Gets point stored at specified index
  8151. * @param index defines the index to look for
  8152. * @returns the requested point if found
  8153. */
  8154. MultiLine.prototype.getAt = function (index) {
  8155. if (!this._points[index]) {
  8156. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8157. }
  8158. return this._points[index];
  8159. };
  8160. /**
  8161. * Adds new points to the point collection
  8162. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8163. * @returns the list of created MultiLinePoint
  8164. */
  8165. MultiLine.prototype.add = function () {
  8166. var _this = this;
  8167. var items = [];
  8168. for (var _i = 0; _i < arguments.length; _i++) {
  8169. items[_i] = arguments[_i];
  8170. }
  8171. return items.map(function (item) { return _this.push(item); });
  8172. };
  8173. /**
  8174. * Adds a new point to the point collection
  8175. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8176. * @returns the created MultiLinePoint
  8177. */
  8178. MultiLine.prototype.push = function (item) {
  8179. var point = this.getAt(this._points.length);
  8180. if (item == null) {
  8181. return point;
  8182. }
  8183. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8184. point.mesh = item;
  8185. }
  8186. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8187. point.control = item;
  8188. }
  8189. else if (item.x != null && item.y != null) {
  8190. point.x = item.x;
  8191. point.y = item.y;
  8192. }
  8193. return point;
  8194. };
  8195. /**
  8196. * Remove a specific value or point from the active point collection
  8197. * @param value defines the value or point to remove
  8198. */
  8199. MultiLine.prototype.remove = function (value) {
  8200. var index;
  8201. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8202. index = this._points.indexOf(value);
  8203. if (index === -1) {
  8204. return;
  8205. }
  8206. }
  8207. else {
  8208. index = value;
  8209. }
  8210. var point = this._points[index];
  8211. if (!point) {
  8212. return;
  8213. }
  8214. point.dispose();
  8215. this._points.splice(index, 1);
  8216. };
  8217. /**
  8218. * Resets this object to initial state (no point)
  8219. */
  8220. MultiLine.prototype.reset = function () {
  8221. while (this._points.length > 0) {
  8222. this.remove(this._points.length - 1);
  8223. }
  8224. };
  8225. /**
  8226. * Resets all links
  8227. */
  8228. MultiLine.prototype.resetLinks = function () {
  8229. this._points.forEach(function (point) {
  8230. if (point != null) {
  8231. point.resetLinks();
  8232. }
  8233. });
  8234. };
  8235. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8236. /** Gets or sets line width */
  8237. get: function () {
  8238. return this._lineWidth;
  8239. },
  8240. set: function (value) {
  8241. if (this._lineWidth === value) {
  8242. return;
  8243. }
  8244. this._lineWidth = value;
  8245. this._markAsDirty();
  8246. },
  8247. enumerable: true,
  8248. configurable: true
  8249. });
  8250. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8251. set: function (value) {
  8252. return;
  8253. },
  8254. enumerable: true,
  8255. configurable: true
  8256. });
  8257. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8258. set: function (value) {
  8259. return;
  8260. },
  8261. enumerable: true,
  8262. configurable: true
  8263. });
  8264. MultiLine.prototype._getTypeName = function () {
  8265. return "MultiLine";
  8266. };
  8267. MultiLine.prototype._draw = function (context) {
  8268. context.save();
  8269. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8270. context.shadowColor = this.shadowColor;
  8271. context.shadowBlur = this.shadowBlur;
  8272. context.shadowOffsetX = this.shadowOffsetX;
  8273. context.shadowOffsetY = this.shadowOffsetY;
  8274. }
  8275. this._applyStates(context);
  8276. context.strokeStyle = this.color;
  8277. context.lineWidth = this._lineWidth;
  8278. context.setLineDash(this._dash);
  8279. context.beginPath();
  8280. var first = true; //first index is not necessarily 0
  8281. this._points.forEach(function (point) {
  8282. if (!point) {
  8283. return;
  8284. }
  8285. if (first) {
  8286. context.moveTo(point._point.x, point._point.y);
  8287. first = false;
  8288. }
  8289. else {
  8290. context.lineTo(point._point.x, point._point.y);
  8291. }
  8292. });
  8293. context.stroke();
  8294. context.restore();
  8295. };
  8296. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8297. var _this = this;
  8298. this._minX = null;
  8299. this._minY = null;
  8300. this._maxX = null;
  8301. this._maxY = null;
  8302. this._points.forEach(function (point, index) {
  8303. if (!point) {
  8304. return;
  8305. }
  8306. point.translate();
  8307. if (_this._minX == null || point._point.x < _this._minX) {
  8308. _this._minX = point._point.x;
  8309. }
  8310. if (_this._minY == null || point._point.y < _this._minY) {
  8311. _this._minY = point._point.y;
  8312. }
  8313. if (_this._maxX == null || point._point.x > _this._maxX) {
  8314. _this._maxX = point._point.x;
  8315. }
  8316. if (_this._maxY == null || point._point.y > _this._maxY) {
  8317. _this._maxY = point._point.y;
  8318. }
  8319. });
  8320. if (this._minX == null) {
  8321. this._minX = 0;
  8322. }
  8323. if (this._minY == null) {
  8324. this._minY = 0;
  8325. }
  8326. if (this._maxX == null) {
  8327. this._maxX = 0;
  8328. }
  8329. if (this._maxY == null) {
  8330. this._maxY = 0;
  8331. }
  8332. };
  8333. MultiLine.prototype._measure = function () {
  8334. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8335. return;
  8336. }
  8337. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8338. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8339. };
  8340. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8341. if (this._minX == null || this._minY == null) {
  8342. return;
  8343. }
  8344. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8345. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8346. };
  8347. MultiLine.prototype.dispose = function () {
  8348. this.reset();
  8349. _super.prototype.dispose.call(this);
  8350. };
  8351. return MultiLine;
  8352. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8353. /***/ }),
  8354. /***/ "./2D/controls/radioButton.ts":
  8355. /*!************************************!*\
  8356. !*** ./2D/controls/radioButton.ts ***!
  8357. \************************************/
  8358. /*! exports provided: RadioButton */
  8359. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8360. "use strict";
  8361. __webpack_require__.r(__webpack_exports__);
  8362. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8363. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8364. <<<<<<< HEAD
  8365. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  8366. =======
  8367. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  8368. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  8369. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8370. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8371. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8372. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8373. /**
  8374. * Class used to create radio button controls
  8375. */
  8376. var RadioButton = /** @class */ (function (_super) {
  8377. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8378. /**
  8379. * Creates a new RadioButton
  8380. * @param name defines the control name
  8381. */
  8382. function RadioButton(name) {
  8383. var _this = _super.call(this, name) || this;
  8384. _this.name = name;
  8385. _this._isChecked = false;
  8386. _this._background = "black";
  8387. _this._checkSizeRatio = 0.8;
  8388. _this._thickness = 1;
  8389. /** Gets or sets group name */
  8390. _this.group = "";
  8391. /** Observable raised when isChecked is changed */
  8392. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8393. _this.isPointerBlocker = true;
  8394. return _this;
  8395. }
  8396. Object.defineProperty(RadioButton.prototype, "thickness", {
  8397. /** Gets or sets border thickness */
  8398. get: function () {
  8399. return this._thickness;
  8400. },
  8401. set: function (value) {
  8402. if (this._thickness === value) {
  8403. return;
  8404. }
  8405. this._thickness = value;
  8406. this._markAsDirty();
  8407. },
  8408. enumerable: true,
  8409. configurable: true
  8410. });
  8411. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8412. /** Gets or sets a value indicating the ratio between overall size and check size */
  8413. get: function () {
  8414. return this._checkSizeRatio;
  8415. },
  8416. set: function (value) {
  8417. value = Math.max(Math.min(1, value), 0);
  8418. if (this._checkSizeRatio === value) {
  8419. return;
  8420. }
  8421. this._checkSizeRatio = value;
  8422. this._markAsDirty();
  8423. },
  8424. enumerable: true,
  8425. configurable: true
  8426. });
  8427. Object.defineProperty(RadioButton.prototype, "background", {
  8428. /** Gets or sets background color */
  8429. get: function () {
  8430. return this._background;
  8431. },
  8432. set: function (value) {
  8433. if (this._background === value) {
  8434. return;
  8435. }
  8436. this._background = value;
  8437. this._markAsDirty();
  8438. },
  8439. enumerable: true,
  8440. configurable: true
  8441. });
  8442. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8443. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8444. get: function () {
  8445. return this._isChecked;
  8446. },
  8447. set: function (value) {
  8448. var _this = this;
  8449. if (this._isChecked === value) {
  8450. return;
  8451. }
  8452. this._isChecked = value;
  8453. this._markAsDirty();
  8454. this.onIsCheckedChangedObservable.notifyObservers(value);
  8455. if (this._isChecked && this._host) {
  8456. // Update all controls from same group
  8457. this._host.executeOnAllControls(function (control) {
  8458. if (control === _this) {
  8459. return;
  8460. }
  8461. if (control.group === undefined) {
  8462. return;
  8463. }
  8464. var childRadio = control;
  8465. if (childRadio.group === _this.group) {
  8466. childRadio.isChecked = false;
  8467. }
  8468. });
  8469. }
  8470. },
  8471. enumerable: true,
  8472. configurable: true
  8473. });
  8474. RadioButton.prototype._getTypeName = function () {
  8475. return "RadioButton";
  8476. };
  8477. RadioButton.prototype._draw = function (context) {
  8478. context.save();
  8479. this._applyStates(context);
  8480. var actualWidth = this._currentMeasure.width - this._thickness;
  8481. var actualHeight = this._currentMeasure.height - this._thickness;
  8482. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8483. context.shadowColor = this.shadowColor;
  8484. context.shadowBlur = this.shadowBlur;
  8485. context.shadowOffsetX = this.shadowOffsetX;
  8486. context.shadowOffsetY = this.shadowOffsetY;
  8487. }
  8488. // Outer
  8489. _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);
  8490. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8491. context.fill();
  8492. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8493. context.shadowBlur = 0;
  8494. context.shadowOffsetX = 0;
  8495. context.shadowOffsetY = 0;
  8496. }
  8497. context.strokeStyle = this.color;
  8498. context.lineWidth = this._thickness;
  8499. context.stroke();
  8500. // Inner
  8501. if (this._isChecked) {
  8502. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8503. var offsetWidth = actualWidth * this._checkSizeRatio;
  8504. var offseHeight = actualHeight * this._checkSizeRatio;
  8505. _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);
  8506. context.fill();
  8507. }
  8508. context.restore();
  8509. };
  8510. // Events
  8511. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8512. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8513. return false;
  8514. }
  8515. if (!this.isChecked) {
  8516. this.isChecked = true;
  8517. }
  8518. return true;
  8519. };
  8520. /**
  8521. * Utility function to easily create a radio button with a header
  8522. * @param title defines the label to use for the header
  8523. * @param group defines the group to use for the radio button
  8524. * @param isChecked defines the initial state of the radio button
  8525. * @param onValueChanged defines the callback to call when value changes
  8526. * @returns a StackPanel containing the radio button and a textBlock
  8527. */
  8528. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8529. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8530. panel.isVertical = false;
  8531. panel.height = "30px";
  8532. var radio = new RadioButton();
  8533. radio.width = "20px";
  8534. radio.height = "20px";
  8535. radio.isChecked = isChecked;
  8536. radio.color = "green";
  8537. radio.group = group;
  8538. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8539. panel.addControl(radio);
  8540. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8541. header.text = title;
  8542. header.width = "180px";
  8543. header.paddingLeft = "5px";
  8544. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8545. header.color = "white";
  8546. panel.addControl(header);
  8547. return panel;
  8548. };
  8549. return RadioButton;
  8550. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8551. /***/ }),
  8552. /***/ "./2D/controls/rectangle.ts":
  8553. /*!**********************************!*\
  8554. !*** ./2D/controls/rectangle.ts ***!
  8555. \**********************************/
  8556. /*! exports provided: Rectangle */
  8557. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8558. "use strict";
  8559. __webpack_require__.r(__webpack_exports__);
  8560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8561. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8562. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8563. /** Class used to create rectangle container */
  8564. var Rectangle = /** @class */ (function (_super) {
  8565. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8566. /**
  8567. * Creates a new Rectangle
  8568. * @param name defines the control name
  8569. */
  8570. function Rectangle(name) {
  8571. var _this = _super.call(this, name) || this;
  8572. _this.name = name;
  8573. _this._thickness = 1;
  8574. _this._cornerRadius = 0;
  8575. return _this;
  8576. }
  8577. Object.defineProperty(Rectangle.prototype, "thickness", {
  8578. /** Gets or sets border thickness */
  8579. get: function () {
  8580. return this._thickness;
  8581. },
  8582. set: function (value) {
  8583. if (this._thickness === value) {
  8584. return;
  8585. }
  8586. this._thickness = value;
  8587. this._markAsDirty();
  8588. },
  8589. enumerable: true,
  8590. configurable: true
  8591. });
  8592. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8593. /** Gets or sets the corner radius angle */
  8594. get: function () {
  8595. return this._cornerRadius;
  8596. },
  8597. set: function (value) {
  8598. if (value < 0) {
  8599. value = 0;
  8600. }
  8601. if (this._cornerRadius === value) {
  8602. return;
  8603. }
  8604. this._cornerRadius = value;
  8605. this._markAsDirty();
  8606. },
  8607. enumerable: true,
  8608. configurable: true
  8609. });
  8610. Rectangle.prototype._getTypeName = function () {
  8611. return "Rectangle";
  8612. };
  8613. Rectangle.prototype._localDraw = function (context) {
  8614. context.save();
  8615. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8616. context.shadowColor = this.shadowColor;
  8617. context.shadowBlur = this.shadowBlur;
  8618. context.shadowOffsetX = this.shadowOffsetX;
  8619. context.shadowOffsetY = this.shadowOffsetY;
  8620. }
  8621. if (this._background) {
  8622. context.fillStyle = this._background;
  8623. if (this._cornerRadius) {
  8624. this._drawRoundedRect(context, this._thickness / 2);
  8625. context.fill();
  8626. }
  8627. else {
  8628. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8629. }
  8630. }
  8631. if (this._thickness) {
  8632. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8633. context.shadowBlur = 0;
  8634. context.shadowOffsetX = 0;
  8635. context.shadowOffsetY = 0;
  8636. }
  8637. if (this.color) {
  8638. context.strokeStyle = this.color;
  8639. }
  8640. context.lineWidth = this._thickness;
  8641. if (this._cornerRadius) {
  8642. this._drawRoundedRect(context, this._thickness / 2);
  8643. context.stroke();
  8644. }
  8645. else {
  8646. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8647. }
  8648. }
  8649. context.restore();
  8650. };
  8651. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8652. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8653. this._measureForChildren.width -= 2 * this._thickness;
  8654. this._measureForChildren.height -= 2 * this._thickness;
  8655. this._measureForChildren.left += this._thickness;
  8656. this._measureForChildren.top += this._thickness;
  8657. };
  8658. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8659. if (offset === void 0) { offset = 0; }
  8660. var x = this._currentMeasure.left + offset;
  8661. var y = this._currentMeasure.top + offset;
  8662. var width = this._currentMeasure.width - offset * 2;
  8663. var height = this._currentMeasure.height - offset * 2;
  8664. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8665. context.beginPath();
  8666. context.moveTo(x + radius, y);
  8667. context.lineTo(x + width - radius, y);
  8668. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8669. context.lineTo(x + width, y + height - radius);
  8670. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8671. context.lineTo(x + radius, y + height);
  8672. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8673. context.lineTo(x, y + radius);
  8674. context.quadraticCurveTo(x, y, x + radius, y);
  8675. context.closePath();
  8676. };
  8677. Rectangle.prototype._clipForChildren = function (context) {
  8678. if (this._cornerRadius) {
  8679. this._drawRoundedRect(context, this._thickness);
  8680. context.clip();
  8681. }
  8682. };
  8683. return Rectangle;
  8684. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8685. /***/ }),
  8686. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8687. /*!***************************************************!*\
  8688. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8689. \***************************************************/
  8690. /*! exports provided: ScrollViewer */
  8691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8692. "use strict";
  8693. __webpack_require__.r(__webpack_exports__);
  8694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8695. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8696. <<<<<<< HEAD
  8697. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/observable");
  8698. =======
  8699. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/tools");
  8700. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  8701. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8702. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8703. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8704. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8705. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8706. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8707. /**
  8708. * Class used to hold a viewer window and sliders in a grid
  8709. */
  8710. var ScrollViewer = /** @class */ (function (_super) {
  8711. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8712. /**
  8713. * Creates a new ScrollViewer
  8714. * @param name of ScrollViewer
  8715. */
  8716. function ScrollViewer(name) {
  8717. var _this = _super.call(this, name) || this;
  8718. _this._barSize = 20;
  8719. _this._pointerIsOver = false;
  8720. _this._wheelPrecision = 0.05;
  8721. _this.onDirtyObservable.add(function () {
  8722. _this._horizontalBarSpace.color = _this.color;
  8723. _this._verticalBarSpace.color = _this.color;
  8724. _this._dragSpace.color = _this.color;
  8725. });
  8726. _this.onPointerEnterObservable.add(function () {
  8727. _this._pointerIsOver = true;
  8728. });
  8729. _this.onPointerOutObservable.add(function () {
  8730. _this._pointerIsOver = false;
  8731. });
  8732. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8733. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8734. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8735. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8736. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8737. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8738. _this._grid.addColumnDefinition(1);
  8739. _this._grid.addColumnDefinition(0, true);
  8740. _this._grid.addRowDefinition(1);
  8741. _this._grid.addRowDefinition(0, true);
  8742. _super.prototype.addControl.call(_this, _this._grid);
  8743. _this._grid.addControl(_this._window, 0, 0);
  8744. _this._verticalBar.paddingLeft = 0;
  8745. _this._verticalBar.width = "100%";
  8746. _this._verticalBar.height = "100%";
  8747. _this._verticalBar.barOffset = 0;
  8748. _this._verticalBar.value = 0;
  8749. _this._verticalBar.maximum = 1;
  8750. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8751. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8752. _this._verticalBar.isVertical = true;
  8753. _this._verticalBar.rotation = Math.PI;
  8754. _this._verticalBar.isVisible = false;
  8755. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8756. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8757. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8758. _this._verticalBarSpace.thickness = 1;
  8759. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8760. _this._verticalBarSpace.addControl(_this._verticalBar);
  8761. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8762. _this._window.top = value * _this._endTop + "px";
  8763. });
  8764. _this._horizontalBar.paddingLeft = 0;
  8765. _this._horizontalBar.width = "100%";
  8766. _this._horizontalBar.height = "100%";
  8767. _this._horizontalBar.barOffset = 0;
  8768. _this._horizontalBar.value = 0;
  8769. _this._horizontalBar.maximum = 1;
  8770. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8771. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8772. _this._horizontalBar.isVisible = false;
  8773. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8774. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8775. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8776. _this._horizontalBarSpace.thickness = 1;
  8777. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8778. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8779. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8780. _this._window.left = value * _this._endLeft + "px";
  8781. });
  8782. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8783. _this._dragSpace.thickness = 1;
  8784. _this._grid.addControl(_this._dragSpace, 1, 1);
  8785. // Colors
  8786. _this.barColor = "grey";
  8787. _this.barBackground = "transparent";
  8788. return _this;
  8789. }
  8790. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8791. /**
  8792. * Gets the horizontal scrollbar
  8793. */
  8794. get: function () {
  8795. return this._horizontalBar;
  8796. },
  8797. enumerable: true,
  8798. configurable: true
  8799. });
  8800. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8801. /**
  8802. * Gets the vertical scrollbar
  8803. */
  8804. get: function () {
  8805. return this._verticalBar;
  8806. },
  8807. enumerable: true,
  8808. configurable: true
  8809. });
  8810. /**
  8811. * Adds a new control to the current container
  8812. * @param control defines the control to add
  8813. * @returns the current container
  8814. */
  8815. ScrollViewer.prototype.addControl = function (control) {
  8816. if (!control) {
  8817. return this;
  8818. }
  8819. this._window.addControl(control);
  8820. return this;
  8821. };
  8822. /**
  8823. * Removes a control from the current container
  8824. * @param control defines the control to remove
  8825. * @returns the current container
  8826. */
  8827. ScrollViewer.prototype.removeControl = function (control) {
  8828. this._window.removeControl(control);
  8829. return this;
  8830. };
  8831. Object.defineProperty(ScrollViewer.prototype, "children", {
  8832. /** Gets the list of children */
  8833. get: function () {
  8834. return this._window.children;
  8835. },
  8836. enumerable: true,
  8837. configurable: true
  8838. });
  8839. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8840. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8841. var child = _a[_i];
  8842. child._markMatrixAsDirty();
  8843. }
  8844. };
  8845. /** Reset the scroll viewer window to initial size */
  8846. ScrollViewer.prototype.resetWindow = function () {
  8847. this._window.width = "100%";
  8848. this._window.height = "100%";
  8849. };
  8850. ScrollViewer.prototype._getTypeName = function () {
  8851. return "ScrollViewer";
  8852. };
  8853. ScrollViewer.prototype._buildClientSizes = function () {
  8854. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8855. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8856. this._clientWidth = this._window.parentClientWidth;
  8857. this._clientHeight = this._window.parentClientHeight;
  8858. };
  8859. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8860. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8861. this._buildClientSizes();
  8862. };
  8863. ScrollViewer.prototype._postMeasure = function () {
  8864. _super.prototype._postMeasure.call(this);
  8865. this._updateScroller();
  8866. };
  8867. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8868. /**
  8869. * Gets or sets the mouse wheel precision
  8870. * from 0 to 1 with a default value of 0.05
  8871. * */
  8872. get: function () {
  8873. return this._wheelPrecision;
  8874. },
  8875. set: function (value) {
  8876. if (this._wheelPrecision === value) {
  8877. return;
  8878. }
  8879. if (value < 0) {
  8880. value = 0;
  8881. }
  8882. if (value > 1) {
  8883. value = 1;
  8884. }
  8885. this._wheelPrecision = value;
  8886. },
  8887. enumerable: true,
  8888. configurable: true
  8889. });
  8890. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8891. /** Gets or sets the bar color */
  8892. get: function () {
  8893. return this._barColor;
  8894. },
  8895. set: function (color) {
  8896. if (this._barColor === color) {
  8897. return;
  8898. }
  8899. this._barColor = color;
  8900. this._horizontalBar.color = color;
  8901. this._verticalBar.color = color;
  8902. },
  8903. enumerable: true,
  8904. configurable: true
  8905. });
  8906. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8907. /** Gets or sets the size of the bar */
  8908. get: function () {
  8909. return this._barSize;
  8910. },
  8911. set: function (value) {
  8912. if (this._barSize === value) {
  8913. return;
  8914. }
  8915. this._barSize = value;
  8916. this._markAsDirty();
  8917. if (this._horizontalBar.isVisible) {
  8918. this._grid.setRowDefinition(1, this._barSize, true);
  8919. }
  8920. if (this._verticalBar.isVisible) {
  8921. this._grid.setColumnDefinition(1, this._barSize, true);
  8922. }
  8923. },
  8924. enumerable: true,
  8925. configurable: true
  8926. });
  8927. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8928. /** Gets or sets the bar background */
  8929. get: function () {
  8930. return this._barBackground;
  8931. },
  8932. set: function (color) {
  8933. if (this._barBackground === color) {
  8934. return;
  8935. }
  8936. this._barBackground = color;
  8937. this._horizontalBar.background = color;
  8938. this._verticalBar.background = color;
  8939. this._dragSpace.background = color;
  8940. },
  8941. enumerable: true,
  8942. configurable: true
  8943. });
  8944. /** @hidden */
  8945. ScrollViewer.prototype._updateScroller = function () {
  8946. var windowContentsWidth = this._window._currentMeasure.width;
  8947. var windowContentsHeight = this._window._currentMeasure.height;
  8948. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8949. this._grid.setRowDefinition(1, 0, true);
  8950. this._horizontalBar.isVisible = false;
  8951. this._horizontalBar.value = 0;
  8952. this._rebuildLayout = true;
  8953. }
  8954. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8955. this._grid.setRowDefinition(1, this._barSize, true);
  8956. this._horizontalBar.isVisible = true;
  8957. this._rebuildLayout = true;
  8958. }
  8959. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8960. this._grid.setColumnDefinition(1, 0, true);
  8961. this._verticalBar.isVisible = false;
  8962. this._verticalBar.value = 0;
  8963. this._rebuildLayout = true;
  8964. }
  8965. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8966. this._grid.setColumnDefinition(1, this._barSize, true);
  8967. this._verticalBar.isVisible = true;
  8968. this._rebuildLayout = true;
  8969. }
  8970. this._buildClientSizes();
  8971. this._endLeft = this._clientWidth - windowContentsWidth;
  8972. this._endTop = this._clientHeight - windowContentsHeight;
  8973. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8974. var newTop = this._verticalBar.value * this._endTop + "px";
  8975. if (newLeft !== this._window.left) {
  8976. this._window.left = newLeft;
  8977. this._rebuildLayout = true;
  8978. }
  8979. if (newTop !== this._window.top) {
  8980. this._window.top = newTop;
  8981. this._rebuildLayout = true;
  8982. }
  8983. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8984. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8985. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8986. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8987. };
  8988. ScrollViewer.prototype._link = function (host) {
  8989. _super.prototype._link.call(this, host);
  8990. this._attachWheel();
  8991. };
  8992. /** @hidden */
  8993. ScrollViewer.prototype._attachWheel = function () {
  8994. var _this = this;
  8995. if (!this._host || this._onPointerObserver) {
  8996. return;
  8997. }
  8998. var scene = this._host.getScene();
  8999. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9000. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9001. return;
  9002. }
  9003. if (_this._verticalBar.isVisible == true) {
  9004. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9005. _this._verticalBar.value -= _this._wheelPrecision;
  9006. }
  9007. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9008. _this._verticalBar.value += _this._wheelPrecision;
  9009. }
  9010. }
  9011. if (_this._horizontalBar.isVisible == true) {
  9012. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9013. _this._horizontalBar.value += _this._wheelPrecision;
  9014. }
  9015. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9016. _this._horizontalBar.value -= _this._wheelPrecision;
  9017. }
  9018. }
  9019. });
  9020. };
  9021. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9022. if (!this.isHighlighted) {
  9023. return;
  9024. }
  9025. _super.prototype._renderHighlightSpecific.call(this, context);
  9026. this._grid._renderHighlightSpecific(context);
  9027. context.restore();
  9028. };
  9029. /** Releases associated resources */
  9030. ScrollViewer.prototype.dispose = function () {
  9031. var scene = this._host.getScene();
  9032. if (scene && this._onPointerObserver) {
  9033. scene.onPointerObservable.remove(this._onPointerObserver);
  9034. this._onPointerObserver = null;
  9035. }
  9036. _super.prototype.dispose.call(this);
  9037. };
  9038. return ScrollViewer;
  9039. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9040. /***/ }),
  9041. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9042. /*!*********************************************************!*\
  9043. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9044. \*********************************************************/
  9045. /*! exports provided: _ScrollViewerWindow */
  9046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9047. "use strict";
  9048. __webpack_require__.r(__webpack_exports__);
  9049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9050. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9051. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9052. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9053. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9054. /**
  9055. * Class used to hold a the container for ScrollViewer
  9056. * @hidden
  9057. */
  9058. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9059. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  9060. /**
  9061. * Creates a new ScrollViewerWindow
  9062. * @param name of ScrollViewerWindow
  9063. */
  9064. function _ScrollViewerWindow(name) {
  9065. return _super.call(this, name) || this;
  9066. }
  9067. _ScrollViewerWindow.prototype._getTypeName = function () {
  9068. return "ScrollViewerWindow";
  9069. };
  9070. /** @hidden */
  9071. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9072. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9073. this._measureForChildren.left = this._currentMeasure.left;
  9074. this._measureForChildren.top = this._currentMeasure.top;
  9075. this._measureForChildren.width = parentMeasure.width;
  9076. this._measureForChildren.height = parentMeasure.height;
  9077. };
  9078. _ScrollViewerWindow.prototype._postMeasure = function () {
  9079. var maxWidth = this.parentClientWidth;
  9080. var maxHeight = this.parentClientHeight;
  9081. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9082. var child = _a[_i];
  9083. if (!child.isVisible || child.notRenderable) {
  9084. continue;
  9085. }
  9086. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9087. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9088. }
  9089. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9090. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9091. }
  9092. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9093. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9094. }
  9095. if (this._currentMeasure.width !== maxWidth) {
  9096. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9097. this._currentMeasure.width = maxWidth;
  9098. this._rebuildLayout = true;
  9099. this._isDirty = true;
  9100. }
  9101. if (this._currentMeasure.height !== maxHeight) {
  9102. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9103. this._currentMeasure.height = maxHeight;
  9104. this._rebuildLayout = true;
  9105. this._isDirty = true;
  9106. }
  9107. _super.prototype._postMeasure.call(this);
  9108. };
  9109. return _ScrollViewerWindow;
  9110. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9111. /***/ }),
  9112. /***/ "./2D/controls/selector.ts":
  9113. /*!*********************************!*\
  9114. !*** ./2D/controls/selector.ts ***!
  9115. \*********************************/
  9116. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9118. "use strict";
  9119. __webpack_require__.r(__webpack_exports__);
  9120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9125. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9126. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9127. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9128. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9129. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9130. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9131. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9132. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9133. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9134. /** Class used to create a RadioGroup
  9135. * which contains groups of radio buttons
  9136. */
  9137. var SelectorGroup = /** @class */ (function () {
  9138. /**
  9139. * Creates a new SelectorGroup
  9140. * @param name of group, used as a group heading
  9141. */
  9142. function SelectorGroup(
  9143. /** name of SelectorGroup */
  9144. name) {
  9145. this.name = name;
  9146. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9147. this._selectors = new Array();
  9148. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9149. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9150. this._groupHeader = this._addGroupHeader(name);
  9151. }
  9152. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9153. /** Gets the groupPanel of the SelectorGroup */
  9154. get: function () {
  9155. return this._groupPanel;
  9156. },
  9157. enumerable: true,
  9158. configurable: true
  9159. });
  9160. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9161. /** Gets the selectors array */
  9162. get: function () {
  9163. return this._selectors;
  9164. },
  9165. enumerable: true,
  9166. configurable: true
  9167. });
  9168. Object.defineProperty(SelectorGroup.prototype, "header", {
  9169. /** Gets and sets the group header */
  9170. get: function () {
  9171. return this._groupHeader.text;
  9172. },
  9173. set: function (label) {
  9174. if (this._groupHeader.text === "label") {
  9175. return;
  9176. }
  9177. this._groupHeader.text = label;
  9178. },
  9179. enumerable: true,
  9180. configurable: true
  9181. });
  9182. /** @hidden */
  9183. SelectorGroup.prototype._addGroupHeader = function (text) {
  9184. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9185. groupHeading.width = 0.9;
  9186. groupHeading.height = "30px";
  9187. groupHeading.textWrapping = true;
  9188. groupHeading.color = "black";
  9189. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9190. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9191. groupHeading.left = "2px";
  9192. this._groupPanel.addControl(groupHeading);
  9193. return groupHeading;
  9194. };
  9195. /** @hidden*/
  9196. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9197. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9198. return;
  9199. }
  9200. return this._selectors[selectorNb];
  9201. };
  9202. /** Removes the selector at the given position
  9203. * @param selectorNb the position of the selector within the group
  9204. */
  9205. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9206. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9207. return;
  9208. }
  9209. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9210. this._selectors.splice(selectorNb, 1);
  9211. };
  9212. return SelectorGroup;
  9213. }());
  9214. /** Class used to create a CheckboxGroup
  9215. * which contains groups of checkbox buttons
  9216. */
  9217. var CheckboxGroup = /** @class */ (function (_super) {
  9218. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9219. function CheckboxGroup() {
  9220. return _super !== null && _super.apply(this, arguments) || this;
  9221. }
  9222. /** Adds a checkbox as a control
  9223. * @param text is the label for the selector
  9224. * @param func is the function called when the Selector is checked
  9225. * @param checked is true when Selector is checked
  9226. */
  9227. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9228. if (func === void 0) { func = function (s) { }; }
  9229. if (checked === void 0) { checked = false; }
  9230. var checked = checked || false;
  9231. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9232. button.width = "20px";
  9233. button.height = "20px";
  9234. button.color = "#364249";
  9235. button.background = "#CCCCCC";
  9236. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9237. button.onIsCheckedChangedObservable.add(function (state) {
  9238. func(state);
  9239. });
  9240. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9241. _selector.height = "30px";
  9242. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9243. _selector.left = "4px";
  9244. this.groupPanel.addControl(_selector);
  9245. this.selectors.push(_selector);
  9246. button.isChecked = checked;
  9247. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9248. button.color = this.groupPanel.parent.parent.buttonColor;
  9249. button.background = this.groupPanel.parent.parent.buttonBackground;
  9250. }
  9251. };
  9252. /** @hidden */
  9253. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9254. this.selectors[selectorNb].children[1].text = label;
  9255. };
  9256. /** @hidden */
  9257. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9258. this.selectors[selectorNb].children[1].color = color;
  9259. };
  9260. /** @hidden */
  9261. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9262. this.selectors[selectorNb].children[0].color = color;
  9263. };
  9264. /** @hidden */
  9265. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9266. this.selectors[selectorNb].children[0].background = color;
  9267. };
  9268. return CheckboxGroup;
  9269. }(SelectorGroup));
  9270. /** Class used to create a RadioGroup
  9271. * which contains groups of radio buttons
  9272. */
  9273. var RadioGroup = /** @class */ (function (_super) {
  9274. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9275. function RadioGroup() {
  9276. var _this = _super !== null && _super.apply(this, arguments) || this;
  9277. _this._selectNb = 0;
  9278. return _this;
  9279. }
  9280. /** Adds a radio button as a control
  9281. * @param label is the label for the selector
  9282. * @param func is the function called when the Selector is checked
  9283. * @param checked is true when Selector is checked
  9284. */
  9285. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9286. if (func === void 0) { func = function (n) { }; }
  9287. if (checked === void 0) { checked = false; }
  9288. var nb = this._selectNb++;
  9289. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9290. button.name = label;
  9291. button.width = "20px";
  9292. button.height = "20px";
  9293. button.color = "#364249";
  9294. button.background = "#CCCCCC";
  9295. button.group = this.name;
  9296. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9297. button.onIsCheckedChangedObservable.add(function (state) {
  9298. if (state) {
  9299. func(nb);
  9300. }
  9301. });
  9302. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9303. _selector.height = "30px";
  9304. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9305. _selector.left = "4px";
  9306. this.groupPanel.addControl(_selector);
  9307. this.selectors.push(_selector);
  9308. button.isChecked = checked;
  9309. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9310. button.color = this.groupPanel.parent.parent.buttonColor;
  9311. button.background = this.groupPanel.parent.parent.buttonBackground;
  9312. }
  9313. };
  9314. /** @hidden */
  9315. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9316. this.selectors[selectorNb].children[1].text = label;
  9317. };
  9318. /** @hidden */
  9319. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9320. this.selectors[selectorNb].children[1].color = color;
  9321. };
  9322. /** @hidden */
  9323. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9324. this.selectors[selectorNb].children[0].color = color;
  9325. };
  9326. /** @hidden */
  9327. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9328. this.selectors[selectorNb].children[0].background = color;
  9329. };
  9330. return RadioGroup;
  9331. }(SelectorGroup));
  9332. /** Class used to create a SliderGroup
  9333. * which contains groups of slider buttons
  9334. */
  9335. var SliderGroup = /** @class */ (function (_super) {
  9336. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9337. function SliderGroup() {
  9338. return _super !== null && _super.apply(this, arguments) || this;
  9339. }
  9340. /**
  9341. * Adds a slider to the SelectorGroup
  9342. * @param label is the label for the SliderBar
  9343. * @param func is the function called when the Slider moves
  9344. * @param unit is a string describing the units used, eg degrees or metres
  9345. * @param min is the minimum value for the Slider
  9346. * @param max is the maximum value for the Slider
  9347. * @param value is the start value for the Slider between min and max
  9348. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9349. */
  9350. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9351. if (func === void 0) { func = function (v) { }; }
  9352. if (unit === void 0) { unit = "Units"; }
  9353. if (min === void 0) { min = 0; }
  9354. if (max === void 0) { max = 0; }
  9355. if (value === void 0) { value = 0; }
  9356. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9357. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9358. button.name = unit;
  9359. button.value = value;
  9360. button.minimum = min;
  9361. button.maximum = max;
  9362. button.width = 0.9;
  9363. button.height = "20px";
  9364. button.color = "#364249";
  9365. button.background = "#CCCCCC";
  9366. button.borderColor = "black";
  9367. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9368. button.left = "4px";
  9369. button.paddingBottom = "4px";
  9370. button.onValueChangedObservable.add(function (value) {
  9371. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9372. func(value);
  9373. });
  9374. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9375. _selector.height = "60px";
  9376. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9377. _selector.left = "4px";
  9378. _selector.children[0].name = label;
  9379. this.groupPanel.addControl(_selector);
  9380. this.selectors.push(_selector);
  9381. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9382. button.color = this.groupPanel.parent.parent.buttonColor;
  9383. button.background = this.groupPanel.parent.parent.buttonBackground;
  9384. }
  9385. };
  9386. /** @hidden */
  9387. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9388. this.selectors[selectorNb].children[0].name = label;
  9389. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9390. };
  9391. /** @hidden */
  9392. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9393. this.selectors[selectorNb].children[0].color = color;
  9394. };
  9395. /** @hidden */
  9396. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9397. this.selectors[selectorNb].children[1].color = color;
  9398. };
  9399. /** @hidden */
  9400. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9401. this.selectors[selectorNb].children[1].background = color;
  9402. };
  9403. return SliderGroup;
  9404. }(SelectorGroup));
  9405. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9406. * @see http://doc.babylonjs.com/how_to/selector
  9407. */
  9408. var SelectionPanel = /** @class */ (function (_super) {
  9409. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9410. /**
  9411. * Creates a new SelectionPanel
  9412. * @param name of SelectionPanel
  9413. * @param groups is an array of SelectionGroups
  9414. */
  9415. function SelectionPanel(
  9416. /** name of SelectionPanel */
  9417. name,
  9418. /** an array of SelectionGroups */
  9419. groups) {
  9420. if (groups === void 0) { groups = []; }
  9421. var _this = _super.call(this, name) || this;
  9422. _this.name = name;
  9423. _this.groups = groups;
  9424. _this._buttonColor = "#364249";
  9425. _this._buttonBackground = "#CCCCCC";
  9426. _this._headerColor = "black";
  9427. _this._barColor = "white";
  9428. _this._barHeight = "2px";
  9429. _this._spacerHeight = "20px";
  9430. _this._bars = new Array();
  9431. _this._groups = groups;
  9432. _this.thickness = 2;
  9433. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9434. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9435. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9436. _this._panel.top = 5;
  9437. _this._panel.left = 5;
  9438. _this._panel.width = 0.95;
  9439. if (groups.length > 0) {
  9440. for (var i = 0; i < groups.length - 1; i++) {
  9441. _this._panel.addControl(groups[i].groupPanel);
  9442. _this._addSpacer();
  9443. }
  9444. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9445. }
  9446. _this.addControl(_this._panel);
  9447. return _this;
  9448. }
  9449. SelectionPanel.prototype._getTypeName = function () {
  9450. return "SelectionPanel";
  9451. };
  9452. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9453. /** Gets or sets the headerColor */
  9454. get: function () {
  9455. return this._headerColor;
  9456. },
  9457. set: function (color) {
  9458. if (this._headerColor === color) {
  9459. return;
  9460. }
  9461. this._headerColor = color;
  9462. this._setHeaderColor();
  9463. },
  9464. enumerable: true,
  9465. configurable: true
  9466. });
  9467. SelectionPanel.prototype._setHeaderColor = function () {
  9468. for (var i = 0; i < this._groups.length; i++) {
  9469. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9470. }
  9471. };
  9472. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9473. /** Gets or sets the button color */
  9474. get: function () {
  9475. return this._buttonColor;
  9476. },
  9477. set: function (color) {
  9478. if (this._buttonColor === color) {
  9479. return;
  9480. }
  9481. this._buttonColor = color;
  9482. this._setbuttonColor();
  9483. },
  9484. enumerable: true,
  9485. configurable: true
  9486. });
  9487. SelectionPanel.prototype._setbuttonColor = function () {
  9488. for (var i = 0; i < this._groups.length; i++) {
  9489. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9490. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9491. }
  9492. }
  9493. };
  9494. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9495. /** Gets or sets the label color */
  9496. get: function () {
  9497. return this._labelColor;
  9498. },
  9499. set: function (color) {
  9500. if (this._labelColor === color) {
  9501. return;
  9502. }
  9503. this._labelColor = color;
  9504. this._setLabelColor();
  9505. },
  9506. enumerable: true,
  9507. configurable: true
  9508. });
  9509. SelectionPanel.prototype._setLabelColor = function () {
  9510. for (var i = 0; i < this._groups.length; i++) {
  9511. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9512. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9513. }
  9514. }
  9515. };
  9516. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9517. /** Gets or sets the button background */
  9518. get: function () {
  9519. return this._buttonBackground;
  9520. },
  9521. set: function (color) {
  9522. if (this._buttonBackground === color) {
  9523. return;
  9524. }
  9525. this._buttonBackground = color;
  9526. this._setButtonBackground();
  9527. },
  9528. enumerable: true,
  9529. configurable: true
  9530. });
  9531. SelectionPanel.prototype._setButtonBackground = function () {
  9532. for (var i = 0; i < this._groups.length; i++) {
  9533. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9534. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9535. }
  9536. }
  9537. };
  9538. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9539. /** Gets or sets the color of separator bar */
  9540. get: function () {
  9541. return this._barColor;
  9542. },
  9543. set: function (color) {
  9544. if (this._barColor === color) {
  9545. return;
  9546. }
  9547. this._barColor = color;
  9548. this._setBarColor();
  9549. },
  9550. enumerable: true,
  9551. configurable: true
  9552. });
  9553. SelectionPanel.prototype._setBarColor = function () {
  9554. for (var i = 0; i < this._bars.length; i++) {
  9555. this._bars[i].children[0].background = this._barColor;
  9556. }
  9557. };
  9558. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9559. /** Gets or sets the height of separator bar */
  9560. get: function () {
  9561. return this._barHeight;
  9562. },
  9563. set: function (value) {
  9564. if (this._barHeight === value) {
  9565. return;
  9566. }
  9567. this._barHeight = value;
  9568. this._setBarHeight();
  9569. },
  9570. enumerable: true,
  9571. configurable: true
  9572. });
  9573. SelectionPanel.prototype._setBarHeight = function () {
  9574. for (var i = 0; i < this._bars.length; i++) {
  9575. this._bars[i].children[0].height = this._barHeight;
  9576. }
  9577. };
  9578. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9579. /** Gets or sets the height of spacers*/
  9580. get: function () {
  9581. return this._spacerHeight;
  9582. },
  9583. set: function (value) {
  9584. if (this._spacerHeight === value) {
  9585. return;
  9586. }
  9587. this._spacerHeight = value;
  9588. this._setSpacerHeight();
  9589. },
  9590. enumerable: true,
  9591. configurable: true
  9592. });
  9593. SelectionPanel.prototype._setSpacerHeight = function () {
  9594. for (var i = 0; i < this._bars.length; i++) {
  9595. this._bars[i].height = this._spacerHeight;
  9596. }
  9597. };
  9598. /** Adds a bar between groups */
  9599. SelectionPanel.prototype._addSpacer = function () {
  9600. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9601. separator.width = 1;
  9602. separator.height = this._spacerHeight;
  9603. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9604. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9605. bar.width = 1;
  9606. bar.height = this._barHeight;
  9607. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9608. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9609. bar.background = this._barColor;
  9610. bar.color = "transparent";
  9611. separator.addControl(bar);
  9612. this._panel.addControl(separator);
  9613. this._bars.push(separator);
  9614. };
  9615. /** Add a group to the selection panel
  9616. * @param group is the selector group to add
  9617. */
  9618. SelectionPanel.prototype.addGroup = function (group) {
  9619. if (this._groups.length > 0) {
  9620. this._addSpacer();
  9621. }
  9622. this._panel.addControl(group.groupPanel);
  9623. this._groups.push(group);
  9624. group.groupPanel.children[0].color = this._headerColor;
  9625. for (var j = 0; j < group.selectors.length; j++) {
  9626. group._setSelectorButtonColor(j, this._buttonColor);
  9627. group._setSelectorButtonBackground(j, this._buttonBackground);
  9628. }
  9629. };
  9630. /** Remove the group from the given position
  9631. * @param groupNb is the position of the group in the list
  9632. */
  9633. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9634. if (groupNb < 0 || groupNb >= this._groups.length) {
  9635. return;
  9636. }
  9637. var group = this._groups[groupNb];
  9638. this._panel.removeControl(group.groupPanel);
  9639. this._groups.splice(groupNb, 1);
  9640. if (groupNb < this._bars.length) {
  9641. this._panel.removeControl(this._bars[groupNb]);
  9642. this._bars.splice(groupNb, 1);
  9643. }
  9644. };
  9645. /** Change a group header label
  9646. * @param label is the new group header label
  9647. * @param groupNb is the number of the group to relabel
  9648. * */
  9649. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9650. if (groupNb < 0 || groupNb >= this._groups.length) {
  9651. return;
  9652. }
  9653. var group = this._groups[groupNb];
  9654. group.groupPanel.children[0].text = label;
  9655. };
  9656. /** Change selector label to the one given
  9657. * @param label is the new selector label
  9658. * @param groupNb is the number of the groupcontaining the selector
  9659. * @param selectorNb is the number of the selector within a group to relabel
  9660. * */
  9661. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9662. if (groupNb < 0 || groupNb >= this._groups.length) {
  9663. return;
  9664. }
  9665. var group = this._groups[groupNb];
  9666. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9667. return;
  9668. }
  9669. group._setSelectorLabel(selectorNb, label);
  9670. };
  9671. /** For a given group position remove the selector at the given position
  9672. * @param groupNb is the number of the group to remove the selector from
  9673. * @param selectorNb is the number of the selector within the group
  9674. */
  9675. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9676. if (groupNb < 0 || groupNb >= this._groups.length) {
  9677. return;
  9678. }
  9679. var group = this._groups[groupNb];
  9680. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9681. return;
  9682. }
  9683. group.removeSelector(selectorNb);
  9684. };
  9685. /** For a given group position of correct type add a checkbox button
  9686. * @param groupNb is the number of the group to remove the selector from
  9687. * @param label is the label for the selector
  9688. * @param func is the function called when the Selector is checked
  9689. * @param checked is true when Selector is checked
  9690. */
  9691. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9692. if (func === void 0) { func = function () { }; }
  9693. if (checked === void 0) { checked = false; }
  9694. if (groupNb < 0 || groupNb >= this._groups.length) {
  9695. return;
  9696. }
  9697. var group = this._groups[groupNb];
  9698. group.addCheckbox(label, func, checked);
  9699. };
  9700. /** For a given group position of correct type add a radio button
  9701. * @param groupNb is the number of the group to remove the selector from
  9702. * @param label is the label for the selector
  9703. * @param func is the function called when the Selector is checked
  9704. * @param checked is true when Selector is checked
  9705. */
  9706. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9707. if (func === void 0) { func = function () { }; }
  9708. if (checked === void 0) { checked = false; }
  9709. if (groupNb < 0 || groupNb >= this._groups.length) {
  9710. return;
  9711. }
  9712. var group = this._groups[groupNb];
  9713. group.addRadio(label, func, checked);
  9714. };
  9715. /**
  9716. * For a given slider group add a slider
  9717. * @param groupNb is the number of the group to add the slider to
  9718. * @param label is the label for the Slider
  9719. * @param func is the function called when the Slider moves
  9720. * @param unit is a string describing the units used, eg degrees or metres
  9721. * @param min is the minimum value for the Slider
  9722. * @param max is the maximum value for the Slider
  9723. * @param value is the start value for the Slider between min and max
  9724. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9725. */
  9726. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9727. if (func === void 0) { func = function () { }; }
  9728. if (unit === void 0) { unit = "Units"; }
  9729. if (min === void 0) { min = 0; }
  9730. if (max === void 0) { max = 0; }
  9731. if (value === void 0) { value = 0; }
  9732. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9733. if (groupNb < 0 || groupNb >= this._groups.length) {
  9734. return;
  9735. }
  9736. var group = this._groups[groupNb];
  9737. group.addSlider(label, func, unit, min, max, value, onVal);
  9738. };
  9739. return SelectionPanel;
  9740. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9741. /***/ }),
  9742. /***/ "./2D/controls/sliders/baseSlider.ts":
  9743. /*!*******************************************!*\
  9744. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9745. \*******************************************/
  9746. /*! exports provided: BaseSlider */
  9747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9748. "use strict";
  9749. __webpack_require__.r(__webpack_exports__);
  9750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9751. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9752. <<<<<<< HEAD
  9753. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  9754. =======
  9755. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  9756. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  9757. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9758. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9759. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9760. /**
  9761. * Class used to create slider controls
  9762. */
  9763. var BaseSlider = /** @class */ (function (_super) {
  9764. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9765. /**
  9766. * Creates a new BaseSlider
  9767. * @param name defines the control name
  9768. */
  9769. function BaseSlider(name) {
  9770. var _this = _super.call(this, name) || this;
  9771. _this.name = name;
  9772. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9773. _this._minimum = 0;
  9774. _this._maximum = 100;
  9775. _this._value = 50;
  9776. _this._isVertical = false;
  9777. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9778. _this._isThumbClamped = false;
  9779. _this._displayThumb = true;
  9780. _this._step = 0;
  9781. _this._lastPointerDownID = -1;
  9782. // Shared rendering info
  9783. _this._effectiveBarOffset = 0;
  9784. /** Observable raised when the sldier value changes */
  9785. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9786. // Events
  9787. _this._pointerIsDown = false;
  9788. _this.isPointerBlocker = true;
  9789. return _this;
  9790. }
  9791. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9792. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9793. get: function () {
  9794. return this._displayThumb;
  9795. },
  9796. set: function (value) {
  9797. if (this._displayThumb === value) {
  9798. return;
  9799. }
  9800. this._displayThumb = value;
  9801. this._markAsDirty();
  9802. },
  9803. enumerable: true,
  9804. configurable: true
  9805. });
  9806. Object.defineProperty(BaseSlider.prototype, "step", {
  9807. /** Gets or sets a step to apply to values (0 by default) */
  9808. get: function () {
  9809. return this._step;
  9810. },
  9811. set: function (value) {
  9812. if (this._step === value) {
  9813. return;
  9814. }
  9815. this._step = value;
  9816. this._markAsDirty();
  9817. },
  9818. enumerable: true,
  9819. configurable: true
  9820. });
  9821. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9822. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9823. get: function () {
  9824. return this._barOffset.toString(this._host);
  9825. },
  9826. set: function (value) {
  9827. if (this._barOffset.toString(this._host) === value) {
  9828. return;
  9829. }
  9830. if (this._barOffset.fromString(value)) {
  9831. this._markAsDirty();
  9832. }
  9833. },
  9834. enumerable: true,
  9835. configurable: true
  9836. });
  9837. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9838. /** Gets main bar offset in pixels*/
  9839. get: function () {
  9840. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9841. },
  9842. enumerable: true,
  9843. configurable: true
  9844. });
  9845. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9846. /** Gets or sets thumb width */
  9847. get: function () {
  9848. return this._thumbWidth.toString(this._host);
  9849. },
  9850. set: function (value) {
  9851. if (this._thumbWidth.toString(this._host) === value) {
  9852. return;
  9853. }
  9854. if (this._thumbWidth.fromString(value)) {
  9855. this._markAsDirty();
  9856. }
  9857. },
  9858. enumerable: true,
  9859. configurable: true
  9860. });
  9861. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9862. /** Gets thumb width in pixels */
  9863. get: function () {
  9864. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9865. },
  9866. enumerable: true,
  9867. configurable: true
  9868. });
  9869. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9870. /** Gets or sets minimum value */
  9871. get: function () {
  9872. return this._minimum;
  9873. },
  9874. set: function (value) {
  9875. if (this._minimum === value) {
  9876. return;
  9877. }
  9878. this._minimum = value;
  9879. this._markAsDirty();
  9880. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9881. },
  9882. enumerable: true,
  9883. configurable: true
  9884. });
  9885. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9886. /** Gets or sets maximum value */
  9887. get: function () {
  9888. return this._maximum;
  9889. },
  9890. set: function (value) {
  9891. if (this._maximum === value) {
  9892. return;
  9893. }
  9894. this._maximum = value;
  9895. this._markAsDirty();
  9896. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9897. },
  9898. enumerable: true,
  9899. configurable: true
  9900. });
  9901. Object.defineProperty(BaseSlider.prototype, "value", {
  9902. /** Gets or sets current value */
  9903. get: function () {
  9904. return this._value;
  9905. },
  9906. set: function (value) {
  9907. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9908. if (this._value === value) {
  9909. return;
  9910. }
  9911. this._value = value;
  9912. this._markAsDirty();
  9913. this.onValueChangedObservable.notifyObservers(this._value);
  9914. },
  9915. enumerable: true,
  9916. configurable: true
  9917. });
  9918. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9919. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9920. get: function () {
  9921. return this._isVertical;
  9922. },
  9923. set: function (value) {
  9924. if (this._isVertical === value) {
  9925. return;
  9926. }
  9927. this._isVertical = value;
  9928. this._markAsDirty();
  9929. },
  9930. enumerable: true,
  9931. configurable: true
  9932. });
  9933. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9934. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9935. get: function () {
  9936. return this._isThumbClamped;
  9937. },
  9938. set: function (value) {
  9939. if (this._isThumbClamped === value) {
  9940. return;
  9941. }
  9942. this._isThumbClamped = value;
  9943. this._markAsDirty();
  9944. },
  9945. enumerable: true,
  9946. configurable: true
  9947. });
  9948. BaseSlider.prototype._getTypeName = function () {
  9949. return "BaseSlider";
  9950. };
  9951. BaseSlider.prototype._getThumbPosition = function () {
  9952. if (this.isVertical) {
  9953. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9954. }
  9955. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9956. };
  9957. BaseSlider.prototype._getThumbThickness = function (type) {
  9958. var thumbThickness = 0;
  9959. switch (type) {
  9960. case "circle":
  9961. if (this._thumbWidth.isPixel) {
  9962. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9963. }
  9964. else {
  9965. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9966. }
  9967. break;
  9968. case "rectangle":
  9969. if (this._thumbWidth.isPixel) {
  9970. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9971. }
  9972. else {
  9973. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9974. }
  9975. }
  9976. return thumbThickness;
  9977. };
  9978. BaseSlider.prototype._prepareRenderingData = function (type) {
  9979. // Main bar
  9980. this._effectiveBarOffset = 0;
  9981. this._renderLeft = this._currentMeasure.left;
  9982. this._renderTop = this._currentMeasure.top;
  9983. this._renderWidth = this._currentMeasure.width;
  9984. this._renderHeight = this._currentMeasure.height;
  9985. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9986. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9987. this._effectiveThumbThickness = this._getThumbThickness(type);
  9988. if (this.displayThumb) {
  9989. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9990. }
  9991. //throw error when height is less than width for vertical slider
  9992. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9993. console.error("Height should be greater than width");
  9994. return;
  9995. }
  9996. if (this._barOffset.isPixel) {
  9997. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9998. }
  9999. else {
  10000. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10001. }
  10002. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10003. if (this.isVertical) {
  10004. this._renderLeft += this._effectiveBarOffset;
  10005. if (!this.isThumbClamped && this.displayThumb) {
  10006. this._renderTop += (this._effectiveThumbThickness / 2);
  10007. }
  10008. this._renderHeight = this._backgroundBoxLength;
  10009. this._renderWidth = this._backgroundBoxThickness;
  10010. }
  10011. else {
  10012. this._renderTop += this._effectiveBarOffset;
  10013. if (!this.isThumbClamped && this.displayThumb) {
  10014. this._renderLeft += (this._effectiveThumbThickness / 2);
  10015. }
  10016. this._renderHeight = this._backgroundBoxThickness;
  10017. this._renderWidth = this._backgroundBoxLength;
  10018. }
  10019. };
  10020. /** @hidden */
  10021. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10022. if (this.rotation != 0) {
  10023. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10024. x = this._transformedPosition.x;
  10025. y = this._transformedPosition.y;
  10026. }
  10027. var value;
  10028. if (this._isVertical) {
  10029. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10030. }
  10031. else {
  10032. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10033. }
  10034. var mult = (1 / this._step) | 0;
  10035. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10036. };
  10037. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10038. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10039. return false;
  10040. }
  10041. this._pointerIsDown = true;
  10042. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10043. this._host._capturingControl[pointerId] = this;
  10044. this._lastPointerDownID = pointerId;
  10045. return true;
  10046. };
  10047. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10048. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10049. if (pointerId != this._lastPointerDownID) {
  10050. return;
  10051. }
  10052. if (this._pointerIsDown) {
  10053. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10054. }
  10055. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10056. };
  10057. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10058. this._pointerIsDown = false;
  10059. delete this._host._capturingControl[pointerId];
  10060. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10061. };
  10062. return BaseSlider;
  10063. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10064. /***/ }),
  10065. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10066. /*!*************************************************!*\
  10067. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10068. \*************************************************/
  10069. /*! exports provided: ImageBasedSlider */
  10070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10071. "use strict";
  10072. __webpack_require__.r(__webpack_exports__);
  10073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10074. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10075. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10076. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10077. /**
  10078. * Class used to create slider controls based on images
  10079. */
  10080. var ImageBasedSlider = /** @class */ (function (_super) {
  10081. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  10082. /**
  10083. * Creates a new ImageBasedSlider
  10084. * @param name defines the control name
  10085. */
  10086. function ImageBasedSlider(name) {
  10087. var _this = _super.call(this, name) || this;
  10088. _this.name = name;
  10089. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10090. return _this;
  10091. }
  10092. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10093. get: function () {
  10094. return this._displayThumb && this.thumbImage != null;
  10095. },
  10096. set: function (value) {
  10097. if (this._displayThumb === value) {
  10098. return;
  10099. }
  10100. this._displayThumb = value;
  10101. this._markAsDirty();
  10102. },
  10103. enumerable: true,
  10104. configurable: true
  10105. });
  10106. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10107. /**
  10108. * Gets or sets the image used to render the background
  10109. */
  10110. get: function () {
  10111. return this._backgroundImage;
  10112. },
  10113. set: function (value) {
  10114. var _this = this;
  10115. if (this._backgroundImage === value) {
  10116. return;
  10117. }
  10118. this._backgroundImage = value;
  10119. if (value && !value.isLoaded) {
  10120. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10121. }
  10122. this._markAsDirty();
  10123. },
  10124. enumerable: true,
  10125. configurable: true
  10126. });
  10127. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10128. /**
  10129. * Gets or sets the image used to render the value bar
  10130. */
  10131. get: function () {
  10132. return this._valueBarImage;
  10133. },
  10134. set: function (value) {
  10135. var _this = this;
  10136. if (this._valueBarImage === value) {
  10137. return;
  10138. }
  10139. this._valueBarImage = value;
  10140. if (value && !value.isLoaded) {
  10141. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10142. }
  10143. this._markAsDirty();
  10144. },
  10145. enumerable: true,
  10146. configurable: true
  10147. });
  10148. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10149. /**
  10150. * Gets or sets the image used to render the thumb
  10151. */
  10152. get: function () {
  10153. return this._thumbImage;
  10154. },
  10155. set: function (value) {
  10156. var _this = this;
  10157. if (this._thumbImage === value) {
  10158. return;
  10159. }
  10160. this._thumbImage = value;
  10161. if (value && !value.isLoaded) {
  10162. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10163. }
  10164. this._markAsDirty();
  10165. },
  10166. enumerable: true,
  10167. configurable: true
  10168. });
  10169. ImageBasedSlider.prototype._getTypeName = function () {
  10170. return "ImageBasedSlider";
  10171. };
  10172. ImageBasedSlider.prototype._draw = function (context) {
  10173. context.save();
  10174. this._applyStates(context);
  10175. this._prepareRenderingData("rectangle");
  10176. var thumbPosition = this._getThumbPosition();
  10177. var left = this._renderLeft;
  10178. var top = this._renderTop;
  10179. var width = this._renderWidth;
  10180. var height = this._renderHeight;
  10181. // Background
  10182. if (this._backgroundImage) {
  10183. this._tempMeasure.copyFromFloats(left, top, width, height);
  10184. if (this.isThumbClamped && this.displayThumb) {
  10185. if (this.isVertical) {
  10186. this._tempMeasure.height += this._effectiveThumbThickness;
  10187. }
  10188. else {
  10189. this._tempMeasure.width += this._effectiveThumbThickness;
  10190. }
  10191. }
  10192. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10193. this._backgroundImage._draw(context);
  10194. }
  10195. // Bar
  10196. if (this._valueBarImage) {
  10197. if (this.isVertical) {
  10198. if (this.isThumbClamped && this.displayThumb) {
  10199. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10200. }
  10201. else {
  10202. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10203. }
  10204. }
  10205. else {
  10206. if (this.isThumbClamped && this.displayThumb) {
  10207. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10208. }
  10209. else {
  10210. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10211. }
  10212. }
  10213. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10214. this._valueBarImage._draw(context);
  10215. }
  10216. // Thumb
  10217. if (this.displayThumb) {
  10218. if (this.isVertical) {
  10219. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10220. }
  10221. else {
  10222. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10223. }
  10224. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10225. this._thumbImage._draw(context);
  10226. }
  10227. context.restore();
  10228. };
  10229. return ImageBasedSlider;
  10230. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10231. /***/ }),
  10232. /***/ "./2D/controls/sliders/scrollBar.ts":
  10233. /*!******************************************!*\
  10234. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10235. \******************************************/
  10236. /*! exports provided: ScrollBar */
  10237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10238. "use strict";
  10239. __webpack_require__.r(__webpack_exports__);
  10240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10241. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10242. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10243. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10244. /**
  10245. * Class used to create slider controls
  10246. */
  10247. var ScrollBar = /** @class */ (function (_super) {
  10248. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10249. /**
  10250. * Creates a new Slider
  10251. * @param name defines the control name
  10252. */
  10253. function ScrollBar(name) {
  10254. var _this = _super.call(this, name) || this;
  10255. _this.name = name;
  10256. _this._background = "black";
  10257. _this._borderColor = "white";
  10258. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10259. return _this;
  10260. }
  10261. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10262. /** Gets or sets border color */
  10263. get: function () {
  10264. return this._borderColor;
  10265. },
  10266. set: function (value) {
  10267. if (this._borderColor === value) {
  10268. return;
  10269. }
  10270. this._borderColor = value;
  10271. this._markAsDirty();
  10272. },
  10273. enumerable: true,
  10274. configurable: true
  10275. });
  10276. Object.defineProperty(ScrollBar.prototype, "background", {
  10277. /** Gets or sets background color */
  10278. get: function () {
  10279. return this._background;
  10280. },
  10281. set: function (value) {
  10282. if (this._background === value) {
  10283. return;
  10284. }
  10285. this._background = value;
  10286. this._markAsDirty();
  10287. },
  10288. enumerable: true,
  10289. configurable: true
  10290. });
  10291. ScrollBar.prototype._getTypeName = function () {
  10292. return "Scrollbar";
  10293. };
  10294. ScrollBar.prototype._getThumbThickness = function () {
  10295. var thumbThickness = 0;
  10296. if (this._thumbWidth.isPixel) {
  10297. thumbThickness = this._thumbWidth.getValue(this._host);
  10298. }
  10299. else {
  10300. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10301. }
  10302. return thumbThickness;
  10303. };
  10304. ScrollBar.prototype._draw = function (context) {
  10305. context.save();
  10306. this._applyStates(context);
  10307. this._prepareRenderingData("rectangle");
  10308. var left = this._renderLeft;
  10309. var thumbPosition = this._getThumbPosition();
  10310. context.fillStyle = this._background;
  10311. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10312. // Value bar
  10313. context.fillStyle = this.color;
  10314. // Thumb
  10315. if (this.isVertical) {
  10316. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10317. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10318. this._thumbMeasure.width = this._currentMeasure.width;
  10319. this._thumbMeasure.height = this._effectiveThumbThickness;
  10320. }
  10321. else {
  10322. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10323. this._thumbMeasure.top = this._currentMeasure.top;
  10324. this._thumbMeasure.width = this._effectiveThumbThickness;
  10325. this._thumbMeasure.height = this._currentMeasure.height;
  10326. }
  10327. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10328. context.restore();
  10329. };
  10330. /** @hidden */
  10331. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10332. if (this.rotation != 0) {
  10333. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10334. x = this._transformedPosition.x;
  10335. y = this._transformedPosition.y;
  10336. }
  10337. if (this._first) {
  10338. this._first = false;
  10339. this._originX = x;
  10340. this._originY = y;
  10341. // Check if move is required
  10342. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10343. if (this.isVertical) {
  10344. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10345. }
  10346. else {
  10347. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10348. }
  10349. }
  10350. }
  10351. // Delta mode
  10352. var delta = 0;
  10353. if (this.isVertical) {
  10354. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10355. }
  10356. else {
  10357. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10358. }
  10359. this.value += delta * (this.maximum - this.minimum);
  10360. this._originX = x;
  10361. this._originY = y;
  10362. };
  10363. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10364. this._first = true;
  10365. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10366. };
  10367. return ScrollBar;
  10368. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10369. /***/ }),
  10370. /***/ "./2D/controls/sliders/slider.ts":
  10371. /*!***************************************!*\
  10372. !*** ./2D/controls/sliders/slider.ts ***!
  10373. \***************************************/
  10374. /*! exports provided: Slider */
  10375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10376. "use strict";
  10377. __webpack_require__.r(__webpack_exports__);
  10378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10379. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10380. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10381. /**
  10382. * Class used to create slider controls
  10383. */
  10384. var Slider = /** @class */ (function (_super) {
  10385. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10386. /**
  10387. * Creates a new Slider
  10388. * @param name defines the control name
  10389. */
  10390. function Slider(name) {
  10391. var _this = _super.call(this, name) || this;
  10392. _this.name = name;
  10393. _this._background = "black";
  10394. _this._borderColor = "white";
  10395. _this._isThumbCircle = false;
  10396. _this._displayValueBar = true;
  10397. return _this;
  10398. }
  10399. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10400. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10401. get: function () {
  10402. return this._displayValueBar;
  10403. },
  10404. set: function (value) {
  10405. if (this._displayValueBar === value) {
  10406. return;
  10407. }
  10408. this._displayValueBar = value;
  10409. this._markAsDirty();
  10410. },
  10411. enumerable: true,
  10412. configurable: true
  10413. });
  10414. Object.defineProperty(Slider.prototype, "borderColor", {
  10415. /** Gets or sets border color */
  10416. get: function () {
  10417. return this._borderColor;
  10418. },
  10419. set: function (value) {
  10420. if (this._borderColor === value) {
  10421. return;
  10422. }
  10423. this._borderColor = value;
  10424. this._markAsDirty();
  10425. },
  10426. enumerable: true,
  10427. configurable: true
  10428. });
  10429. Object.defineProperty(Slider.prototype, "background", {
  10430. /** Gets or sets background color */
  10431. get: function () {
  10432. return this._background;
  10433. },
  10434. set: function (value) {
  10435. if (this._background === value) {
  10436. return;
  10437. }
  10438. this._background = value;
  10439. this._markAsDirty();
  10440. },
  10441. enumerable: true,
  10442. configurable: true
  10443. });
  10444. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10445. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10446. get: function () {
  10447. return this._isThumbCircle;
  10448. },
  10449. set: function (value) {
  10450. if (this._isThumbCircle === value) {
  10451. return;
  10452. }
  10453. this._isThumbCircle = value;
  10454. this._markAsDirty();
  10455. },
  10456. enumerable: true,
  10457. configurable: true
  10458. });
  10459. Slider.prototype._getTypeName = function () {
  10460. return "Slider";
  10461. };
  10462. Slider.prototype._draw = function (context) {
  10463. context.save();
  10464. this._applyStates(context);
  10465. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10466. var left = this._renderLeft;
  10467. var top = this._renderTop;
  10468. var width = this._renderWidth;
  10469. var height = this._renderHeight;
  10470. var radius = 0;
  10471. if (this.isThumbClamped && this.isThumbCircle) {
  10472. if (this.isVertical) {
  10473. top += (this._effectiveThumbThickness / 2);
  10474. }
  10475. else {
  10476. left += (this._effectiveThumbThickness / 2);
  10477. }
  10478. radius = this._backgroundBoxThickness / 2;
  10479. }
  10480. else {
  10481. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10482. }
  10483. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10484. context.shadowColor = this.shadowColor;
  10485. context.shadowBlur = this.shadowBlur;
  10486. context.shadowOffsetX = this.shadowOffsetX;
  10487. context.shadowOffsetY = this.shadowOffsetY;
  10488. }
  10489. var thumbPosition = this._getThumbPosition();
  10490. context.fillStyle = this._background;
  10491. if (this.isVertical) {
  10492. if (this.isThumbClamped) {
  10493. if (this.isThumbCircle) {
  10494. context.beginPath();
  10495. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10496. context.fill();
  10497. context.fillRect(left, top, width, height);
  10498. }
  10499. else {
  10500. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10501. }
  10502. }
  10503. else {
  10504. context.fillRect(left, top, width, height);
  10505. }
  10506. }
  10507. else {
  10508. if (this.isThumbClamped) {
  10509. if (this.isThumbCircle) {
  10510. context.beginPath();
  10511. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10512. context.fill();
  10513. context.fillRect(left, top, width, height);
  10514. }
  10515. else {
  10516. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10517. }
  10518. }
  10519. else {
  10520. context.fillRect(left, top, width, height);
  10521. }
  10522. }
  10523. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10524. context.shadowBlur = 0;
  10525. context.shadowOffsetX = 0;
  10526. context.shadowOffsetY = 0;
  10527. }
  10528. // Value bar
  10529. context.fillStyle = this.color;
  10530. if (this._displayValueBar) {
  10531. if (this.isVertical) {
  10532. if (this.isThumbClamped) {
  10533. if (this.isThumbCircle) {
  10534. context.beginPath();
  10535. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10536. context.fill();
  10537. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10538. }
  10539. else {
  10540. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10541. }
  10542. }
  10543. else {
  10544. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10545. }
  10546. }
  10547. else {
  10548. if (this.isThumbClamped) {
  10549. if (this.isThumbCircle) {
  10550. context.beginPath();
  10551. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10552. context.fill();
  10553. context.fillRect(left, top, thumbPosition, height);
  10554. }
  10555. else {
  10556. context.fillRect(left, top, thumbPosition, height);
  10557. }
  10558. }
  10559. else {
  10560. context.fillRect(left, top, thumbPosition, height);
  10561. }
  10562. }
  10563. }
  10564. // Thumb
  10565. if (this.displayThumb) {
  10566. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10567. context.shadowColor = this.shadowColor;
  10568. context.shadowBlur = this.shadowBlur;
  10569. context.shadowOffsetX = this.shadowOffsetX;
  10570. context.shadowOffsetY = this.shadowOffsetY;
  10571. }
  10572. if (this._isThumbCircle) {
  10573. context.beginPath();
  10574. if (this.isVertical) {
  10575. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10576. }
  10577. else {
  10578. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10579. }
  10580. context.fill();
  10581. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10582. context.shadowBlur = 0;
  10583. context.shadowOffsetX = 0;
  10584. context.shadowOffsetY = 0;
  10585. }
  10586. context.strokeStyle = this._borderColor;
  10587. context.stroke();
  10588. }
  10589. else {
  10590. if (this.isVertical) {
  10591. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10592. }
  10593. else {
  10594. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10595. }
  10596. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10597. context.shadowBlur = 0;
  10598. context.shadowOffsetX = 0;
  10599. context.shadowOffsetY = 0;
  10600. }
  10601. context.strokeStyle = this._borderColor;
  10602. if (this.isVertical) {
  10603. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10604. }
  10605. else {
  10606. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10607. }
  10608. }
  10609. }
  10610. context.restore();
  10611. };
  10612. return Slider;
  10613. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10614. /***/ }),
  10615. /***/ "./2D/controls/stackPanel.ts":
  10616. /*!***********************************!*\
  10617. !*** ./2D/controls/stackPanel.ts ***!
  10618. \***********************************/
  10619. /*! exports provided: StackPanel */
  10620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10621. "use strict";
  10622. __webpack_require__.r(__webpack_exports__);
  10623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10624. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10625. <<<<<<< HEAD
  10626. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  10627. =======
  10628. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  10629. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  10630. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10631. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10632. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10633. /**
  10634. * Class used to create a 2D stack panel container
  10635. */
  10636. var StackPanel = /** @class */ (function (_super) {
  10637. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10638. /**
  10639. * Creates a new StackPanel
  10640. * @param name defines control name
  10641. */
  10642. function StackPanel(name) {
  10643. var _this = _super.call(this, name) || this;
  10644. _this.name = name;
  10645. _this._isVertical = true;
  10646. _this._manualWidth = false;
  10647. _this._manualHeight = false;
  10648. _this._doNotTrackManualChanges = false;
  10649. return _this;
  10650. }
  10651. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10652. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10653. get: function () {
  10654. return this._isVertical;
  10655. },
  10656. set: function (value) {
  10657. if (this._isVertical === value) {
  10658. return;
  10659. }
  10660. this._isVertical = value;
  10661. this._markAsDirty();
  10662. },
  10663. enumerable: true,
  10664. configurable: true
  10665. });
  10666. Object.defineProperty(StackPanel.prototype, "width", {
  10667. get: function () {
  10668. return this._width.toString(this._host);
  10669. },
  10670. /**
  10671. * Gets or sets panel width.
  10672. * This value should not be set when in horizontal mode as it will be computed automatically
  10673. */
  10674. set: function (value) {
  10675. if (!this._doNotTrackManualChanges) {
  10676. this._manualWidth = true;
  10677. }
  10678. if (this._width.toString(this._host) === value) {
  10679. return;
  10680. }
  10681. if (this._width.fromString(value)) {
  10682. this._markAsDirty();
  10683. }
  10684. },
  10685. enumerable: true,
  10686. configurable: true
  10687. });
  10688. Object.defineProperty(StackPanel.prototype, "height", {
  10689. get: function () {
  10690. return this._height.toString(this._host);
  10691. },
  10692. /**
  10693. * Gets or sets panel height.
  10694. * This value should not be set when in vertical mode as it will be computed automatically
  10695. */
  10696. set: function (value) {
  10697. if (!this._doNotTrackManualChanges) {
  10698. this._manualHeight = true;
  10699. }
  10700. if (this._height.toString(this._host) === value) {
  10701. return;
  10702. }
  10703. if (this._height.fromString(value)) {
  10704. this._markAsDirty();
  10705. }
  10706. },
  10707. enumerable: true,
  10708. configurable: true
  10709. });
  10710. StackPanel.prototype._getTypeName = function () {
  10711. return "StackPanel";
  10712. };
  10713. /** @hidden */
  10714. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10715. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10716. var child = _a[_i];
  10717. if (this._isVertical) {
  10718. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10719. }
  10720. else {
  10721. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10722. }
  10723. }
  10724. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10725. };
  10726. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10727. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10728. this._measureForChildren.copyFrom(parentMeasure);
  10729. this._measureForChildren.left = this._currentMeasure.left;
  10730. this._measureForChildren.top = this._currentMeasure.top;
  10731. if (!this.isVertical || this._manualWidth) {
  10732. this._measureForChildren.width = this._currentMeasure.width;
  10733. }
  10734. if (this.isVertical || this._manualHeight) {
  10735. this._measureForChildren.height = this._currentMeasure.height;
  10736. }
  10737. };
  10738. StackPanel.prototype._postMeasure = function () {
  10739. var stackWidth = 0;
  10740. var stackHeight = 0;
  10741. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10742. var child = _a[_i];
  10743. if (!child.isVisible || child.notRenderable) {
  10744. continue;
  10745. }
  10746. if (this._isVertical) {
  10747. if (child.top !== stackHeight + "px") {
  10748. child.top = stackHeight + "px";
  10749. this._rebuildLayout = true;
  10750. child._top.ignoreAdaptiveScaling = true;
  10751. }
  10752. if (child._height.isPercentage) {
  10753. 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");
  10754. }
  10755. else {
  10756. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10757. }
  10758. }
  10759. else {
  10760. if (child.left !== stackWidth + "px") {
  10761. child.left = stackWidth + "px";
  10762. this._rebuildLayout = true;
  10763. child._left.ignoreAdaptiveScaling = true;
  10764. }
  10765. if (child._width.isPercentage) {
  10766. 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");
  10767. }
  10768. else {
  10769. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10770. }
  10771. }
  10772. }
  10773. this._doNotTrackManualChanges = true;
  10774. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10775. // User can now define their own height and width for stack panel.
  10776. var panelWidthChanged = false;
  10777. var panelHeightChanged = false;
  10778. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10779. var previousHeight = this.height;
  10780. this.height = stackHeight + "px";
  10781. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10782. }
  10783. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10784. var previousWidth = this.width;
  10785. this.width = stackWidth + "px";
  10786. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10787. }
  10788. if (panelHeightChanged) {
  10789. this._height.ignoreAdaptiveScaling = true;
  10790. }
  10791. if (panelWidthChanged) {
  10792. this._width.ignoreAdaptiveScaling = true;
  10793. }
  10794. this._doNotTrackManualChanges = false;
  10795. if (panelWidthChanged || panelHeightChanged) {
  10796. this._rebuildLayout = true;
  10797. }
  10798. _super.prototype._postMeasure.call(this);
  10799. };
  10800. return StackPanel;
  10801. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10802. /***/ }),
  10803. /***/ "./2D/controls/statics.ts":
  10804. /*!********************************!*\
  10805. !*** ./2D/controls/statics.ts ***!
  10806. \********************************/
  10807. /*! exports provided: name */
  10808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10809. "use strict";
  10810. __webpack_require__.r(__webpack_exports__);
  10811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10812. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10813. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10814. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10815. /**
  10816. * Forcing an export so that this code will execute
  10817. * @hidden
  10818. */
  10819. var name = "Statics";
  10820. /**
  10821. * Creates a stack panel that can be used to render headers
  10822. * @param control defines the control to associate with the header
  10823. * @param text defines the text of the header
  10824. * @param size defines the size of the header
  10825. * @param options defines options used to configure the header
  10826. * @returns a new StackPanel
  10827. */
  10828. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10829. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10830. var isHorizontal = options ? options.isHorizontal : true;
  10831. var controlFirst = options ? options.controlFirst : true;
  10832. panel.isVertical = !isHorizontal;
  10833. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10834. header.text = text;
  10835. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10836. if (isHorizontal) {
  10837. header.width = size;
  10838. }
  10839. else {
  10840. header.height = size;
  10841. }
  10842. if (controlFirst) {
  10843. panel.addControl(control);
  10844. panel.addControl(header);
  10845. header.paddingLeft = "5px";
  10846. }
  10847. else {
  10848. panel.addControl(header);
  10849. panel.addControl(control);
  10850. header.paddingRight = "5px";
  10851. }
  10852. header.shadowBlur = control.shadowBlur;
  10853. header.shadowColor = control.shadowColor;
  10854. header.shadowOffsetX = control.shadowOffsetX;
  10855. header.shadowOffsetY = control.shadowOffsetY;
  10856. return panel;
  10857. };
  10858. /***/ }),
  10859. /***/ "./2D/controls/textBlock.ts":
  10860. /*!**********************************!*\
  10861. !*** ./2D/controls/textBlock.ts ***!
  10862. \**********************************/
  10863. /*! exports provided: TextWrapping, TextBlock */
  10864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10865. "use strict";
  10866. __webpack_require__.r(__webpack_exports__);
  10867. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10868. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10869. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10870. <<<<<<< HEAD
  10871. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  10872. =======
  10873. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  10874. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  10875. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10876. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10877. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10878. /**
  10879. * Enum that determines the text-wrapping mode to use.
  10880. */
  10881. var TextWrapping;
  10882. (function (TextWrapping) {
  10883. /**
  10884. * Clip the text when it's larger than Control.width; this is the default mode.
  10885. */
  10886. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10887. /**
  10888. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10889. */
  10890. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10891. /**
  10892. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10893. */
  10894. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10895. })(TextWrapping || (TextWrapping = {}));
  10896. /**
  10897. * Class used to create text block control
  10898. */
  10899. var TextBlock = /** @class */ (function (_super) {
  10900. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10901. /**
  10902. * Creates a new TextBlock object
  10903. * @param name defines the name of the control
  10904. * @param text defines the text to display (emptry string by default)
  10905. */
  10906. function TextBlock(
  10907. /**
  10908. * Defines the name of the control
  10909. */
  10910. name, text) {
  10911. if (text === void 0) { text = ""; }
  10912. var _this = _super.call(this, name) || this;
  10913. _this.name = name;
  10914. _this._text = "";
  10915. _this._textWrapping = TextWrapping.Clip;
  10916. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10917. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10918. _this._resizeToFit = false;
  10919. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10920. _this._outlineWidth = 0;
  10921. _this._outlineColor = "white";
  10922. /**
  10923. * An event triggered after the text is changed
  10924. */
  10925. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10926. /**
  10927. * An event triggered after the text was broken up into lines
  10928. */
  10929. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10930. _this.text = text;
  10931. return _this;
  10932. }
  10933. Object.defineProperty(TextBlock.prototype, "lines", {
  10934. /**
  10935. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10936. */
  10937. get: function () {
  10938. return this._lines;
  10939. },
  10940. enumerable: true,
  10941. configurable: true
  10942. });
  10943. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10944. /**
  10945. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10946. */
  10947. get: function () {
  10948. return this._resizeToFit;
  10949. },
  10950. /**
  10951. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10952. */
  10953. set: function (value) {
  10954. if (this._resizeToFit === value) {
  10955. return;
  10956. }
  10957. this._resizeToFit = value;
  10958. if (this._resizeToFit) {
  10959. this._width.ignoreAdaptiveScaling = true;
  10960. this._height.ignoreAdaptiveScaling = true;
  10961. }
  10962. this._markAsDirty();
  10963. },
  10964. enumerable: true,
  10965. configurable: true
  10966. });
  10967. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10968. /**
  10969. * Gets or sets a boolean indicating if text must be wrapped
  10970. */
  10971. get: function () {
  10972. return this._textWrapping;
  10973. },
  10974. /**
  10975. * Gets or sets a boolean indicating if text must be wrapped
  10976. */
  10977. set: function (value) {
  10978. if (this._textWrapping === value) {
  10979. return;
  10980. }
  10981. this._textWrapping = +value;
  10982. this._markAsDirty();
  10983. },
  10984. enumerable: true,
  10985. configurable: true
  10986. });
  10987. Object.defineProperty(TextBlock.prototype, "text", {
  10988. /**
  10989. * Gets or sets text to display
  10990. */
  10991. get: function () {
  10992. return this._text;
  10993. },
  10994. /**
  10995. * Gets or sets text to display
  10996. */
  10997. set: function (value) {
  10998. if (this._text === value) {
  10999. return;
  11000. }
  11001. this._text = value;
  11002. this._markAsDirty();
  11003. this.onTextChangedObservable.notifyObservers(this);
  11004. },
  11005. enumerable: true,
  11006. configurable: true
  11007. });
  11008. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  11009. /**
  11010. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11011. */
  11012. get: function () {
  11013. return this._textHorizontalAlignment;
  11014. },
  11015. /**
  11016. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11017. */
  11018. set: function (value) {
  11019. if (this._textHorizontalAlignment === value) {
  11020. return;
  11021. }
  11022. this._textHorizontalAlignment = value;
  11023. this._markAsDirty();
  11024. },
  11025. enumerable: true,
  11026. configurable: true
  11027. });
  11028. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  11029. /**
  11030. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11031. */
  11032. get: function () {
  11033. return this._textVerticalAlignment;
  11034. },
  11035. /**
  11036. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11037. */
  11038. set: function (value) {
  11039. if (this._textVerticalAlignment === value) {
  11040. return;
  11041. }
  11042. this._textVerticalAlignment = value;
  11043. this._markAsDirty();
  11044. },
  11045. enumerable: true,
  11046. configurable: true
  11047. });
  11048. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11049. /**
  11050. * Gets or sets line spacing value
  11051. */
  11052. get: function () {
  11053. return this._lineSpacing.toString(this._host);
  11054. },
  11055. /**
  11056. * Gets or sets line spacing value
  11057. */
  11058. set: function (value) {
  11059. if (this._lineSpacing.fromString(value)) {
  11060. this._markAsDirty();
  11061. }
  11062. },
  11063. enumerable: true,
  11064. configurable: true
  11065. });
  11066. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11067. /**
  11068. * Gets or sets outlineWidth of the text to display
  11069. */
  11070. get: function () {
  11071. return this._outlineWidth;
  11072. },
  11073. /**
  11074. * Gets or sets outlineWidth of the text to display
  11075. */
  11076. set: function (value) {
  11077. if (this._outlineWidth === value) {
  11078. return;
  11079. }
  11080. this._outlineWidth = value;
  11081. this._markAsDirty();
  11082. },
  11083. enumerable: true,
  11084. configurable: true
  11085. });
  11086. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11087. /**
  11088. * Gets or sets outlineColor of the text to display
  11089. */
  11090. get: function () {
  11091. return this._outlineColor;
  11092. },
  11093. /**
  11094. * Gets or sets outlineColor of the text to display
  11095. */
  11096. set: function (value) {
  11097. if (this._outlineColor === value) {
  11098. return;
  11099. }
  11100. this._outlineColor = value;
  11101. this._markAsDirty();
  11102. },
  11103. enumerable: true,
  11104. configurable: true
  11105. });
  11106. TextBlock.prototype._getTypeName = function () {
  11107. return "TextBlock";
  11108. };
  11109. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11110. if (!this._fontOffset) {
  11111. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11112. }
  11113. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11114. // Prepare lines
  11115. this._lines = this._breakLines(this._currentMeasure.width, context);
  11116. this.onLinesReadyObservable.notifyObservers(this);
  11117. var maxLineWidth = 0;
  11118. for (var i = 0; i < this._lines.length; i++) {
  11119. var line = this._lines[i];
  11120. if (line.width > maxLineWidth) {
  11121. maxLineWidth = line.width;
  11122. }
  11123. }
  11124. if (this._resizeToFit) {
  11125. if (this._textWrapping === TextWrapping.Clip) {
  11126. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11127. if (newWidth !== this._width.internalValue) {
  11128. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11129. this._rebuildLayout = true;
  11130. }
  11131. }
  11132. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11133. if (newHeight !== this._height.internalValue) {
  11134. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11135. this._rebuildLayout = true;
  11136. }
  11137. }
  11138. };
  11139. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11140. var width = this._currentMeasure.width;
  11141. var x = 0;
  11142. switch (this._textHorizontalAlignment) {
  11143. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11144. x = 0;
  11145. break;
  11146. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11147. x = width - textWidth;
  11148. break;
  11149. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11150. x = (width - textWidth) / 2;
  11151. break;
  11152. }
  11153. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11154. context.shadowColor = this.shadowColor;
  11155. context.shadowBlur = this.shadowBlur;
  11156. context.shadowOffsetX = this.shadowOffsetX;
  11157. context.shadowOffsetY = this.shadowOffsetY;
  11158. }
  11159. if (this.outlineWidth) {
  11160. context.strokeText(text, this._currentMeasure.left + x, y);
  11161. }
  11162. context.fillText(text, this._currentMeasure.left + x, y);
  11163. };
  11164. /** @hidden */
  11165. TextBlock.prototype._draw = function (context) {
  11166. context.save();
  11167. this._applyStates(context);
  11168. // Render lines
  11169. this._renderLines(context);
  11170. context.restore();
  11171. };
  11172. TextBlock.prototype._applyStates = function (context) {
  11173. _super.prototype._applyStates.call(this, context);
  11174. if (this.outlineWidth) {
  11175. context.lineWidth = this.outlineWidth;
  11176. context.strokeStyle = this.outlineColor;
  11177. }
  11178. };
  11179. TextBlock.prototype._breakLines = function (refWidth, context) {
  11180. var lines = [];
  11181. var _lines = this.text.split("\n");
  11182. if (this._textWrapping === TextWrapping.Ellipsis) {
  11183. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11184. var _line = _lines_1[_i];
  11185. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11186. }
  11187. }
  11188. else if (this._textWrapping === TextWrapping.WordWrap) {
  11189. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11190. var _line = _lines_2[_a];
  11191. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11192. }
  11193. }
  11194. else {
  11195. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11196. var _line = _lines_3[_b];
  11197. lines.push(this._parseLine(_line, context));
  11198. }
  11199. }
  11200. return lines;
  11201. };
  11202. TextBlock.prototype._parseLine = function (line, context) {
  11203. if (line === void 0) { line = ''; }
  11204. return { text: line, width: context.measureText(line).width };
  11205. };
  11206. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11207. if (line === void 0) { line = ''; }
  11208. var lineWidth = context.measureText(line).width;
  11209. if (lineWidth > width) {
  11210. line += '…';
  11211. }
  11212. while (line.length > 2 && lineWidth > width) {
  11213. line = line.slice(0, -2) + '…';
  11214. lineWidth = context.measureText(line).width;
  11215. }
  11216. return { text: line, width: lineWidth };
  11217. };
  11218. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11219. if (line === void 0) { line = ''; }
  11220. var lines = [];
  11221. var words = line.split(' ');
  11222. var lineWidth = 0;
  11223. for (var n = 0; n < words.length; n++) {
  11224. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11225. var metrics = context.measureText(testLine);
  11226. var testWidth = metrics.width;
  11227. if (testWidth > width && n > 0) {
  11228. lines.push({ text: line, width: lineWidth });
  11229. line = words[n];
  11230. lineWidth = context.measureText(line).width;
  11231. }
  11232. else {
  11233. lineWidth = testWidth;
  11234. line = testLine;
  11235. }
  11236. }
  11237. lines.push({ text: line, width: lineWidth });
  11238. return lines;
  11239. };
  11240. TextBlock.prototype._renderLines = function (context) {
  11241. var height = this._currentMeasure.height;
  11242. var rootY = 0;
  11243. switch (this._textVerticalAlignment) {
  11244. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11245. rootY = this._fontOffset.ascent;
  11246. break;
  11247. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11248. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11249. break;
  11250. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11251. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11252. break;
  11253. }
  11254. rootY += this._currentMeasure.top;
  11255. for (var i = 0; i < this._lines.length; i++) {
  11256. var line = this._lines[i];
  11257. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11258. if (this._lineSpacing.isPixel) {
  11259. rootY += this._lineSpacing.getValue(this._host);
  11260. }
  11261. else {
  11262. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11263. }
  11264. }
  11265. this._drawText(line.text, line.width, rootY, context);
  11266. rootY += this._fontOffset.height;
  11267. }
  11268. };
  11269. /**
  11270. * Given a width constraint applied on the text block, find the expected height
  11271. * @returns expected height
  11272. */
  11273. TextBlock.prototype.computeExpectedHeight = function () {
  11274. if (this.text && this.widthInPixels) {
  11275. var context_1 = document.createElement('canvas').getContext('2d');
  11276. if (context_1) {
  11277. this._applyStates(context_1);
  11278. if (!this._fontOffset) {
  11279. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11280. }
  11281. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11282. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11283. }
  11284. }
  11285. return 0;
  11286. };
  11287. TextBlock.prototype.dispose = function () {
  11288. _super.prototype.dispose.call(this);
  11289. this.onTextChangedObservable.clear();
  11290. };
  11291. return TextBlock;
  11292. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11293. /***/ }),
  11294. /***/ "./2D/controls/virtualKeyboard.ts":
  11295. /*!****************************************!*\
  11296. !*** ./2D/controls/virtualKeyboard.ts ***!
  11297. \****************************************/
  11298. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11300. "use strict";
  11301. __webpack_require__.r(__webpack_exports__);
  11302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11303. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11304. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11305. <<<<<<< HEAD
  11306. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11307. =======
  11308. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  11309. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  11310. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11311. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11312. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11313. /**
  11314. * Class used to store key control properties
  11315. */
  11316. var KeyPropertySet = /** @class */ (function () {
  11317. function KeyPropertySet() {
  11318. }
  11319. return KeyPropertySet;
  11320. }());
  11321. /**
  11322. * Class used to create virtual keyboard
  11323. */
  11324. var VirtualKeyboard = /** @class */ (function (_super) {
  11325. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11326. function VirtualKeyboard() {
  11327. var _this = _super !== null && _super.apply(this, arguments) || this;
  11328. /** Observable raised when a key is pressed */
  11329. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11330. /** Gets or sets default key button width */
  11331. _this.defaultButtonWidth = "40px";
  11332. /** Gets or sets default key button height */
  11333. _this.defaultButtonHeight = "40px";
  11334. /** Gets or sets default key button left padding */
  11335. _this.defaultButtonPaddingLeft = "2px";
  11336. /** Gets or sets default key button right padding */
  11337. _this.defaultButtonPaddingRight = "2px";
  11338. /** Gets or sets default key button top padding */
  11339. _this.defaultButtonPaddingTop = "2px";
  11340. /** Gets or sets default key button bottom padding */
  11341. _this.defaultButtonPaddingBottom = "2px";
  11342. /** Gets or sets default key button foreground color */
  11343. _this.defaultButtonColor = "#DDD";
  11344. /** Gets or sets default key button background color */
  11345. _this.defaultButtonBackground = "#070707";
  11346. /** Gets or sets shift button foreground color */
  11347. _this.shiftButtonColor = "#7799FF";
  11348. /** Gets or sets shift button thickness*/
  11349. _this.selectedShiftThickness = 1;
  11350. /** Gets shift key state */
  11351. _this.shiftState = 0;
  11352. _this._currentlyConnectedInputText = null;
  11353. _this._connectedInputTexts = [];
  11354. _this._onKeyPressObserver = null;
  11355. return _this;
  11356. }
  11357. VirtualKeyboard.prototype._getTypeName = function () {
  11358. return "VirtualKeyboard";
  11359. };
  11360. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11361. var _this = this;
  11362. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11363. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11364. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11365. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11366. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11367. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11368. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11369. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11370. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11371. button.thickness = 0;
  11372. button.isFocusInvisible = true;
  11373. button.shadowColor = this.shadowColor;
  11374. button.shadowBlur = this.shadowBlur;
  11375. button.shadowOffsetX = this.shadowOffsetX;
  11376. button.shadowOffsetY = this.shadowOffsetY;
  11377. button.onPointerUpObservable.add(function () {
  11378. _this.onKeyPressObservable.notifyObservers(key);
  11379. });
  11380. return button;
  11381. };
  11382. /**
  11383. * Adds a new row of keys
  11384. * @param keys defines the list of keys to add
  11385. * @param propertySets defines the associated property sets
  11386. */
  11387. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11388. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11389. panel.isVertical = false;
  11390. panel.isFocusInvisible = true;
  11391. var maxKey = null;
  11392. for (var i = 0; i < keys.length; i++) {
  11393. var properties = null;
  11394. if (propertySets && propertySets.length === keys.length) {
  11395. properties = propertySets[i];
  11396. }
  11397. var key = this._createKey(keys[i], properties);
  11398. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11399. maxKey = key;
  11400. }
  11401. panel.addControl(key);
  11402. }
  11403. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11404. this.addControl(panel);
  11405. };
  11406. /**
  11407. * Set the shift key to a specific state
  11408. * @param shiftState defines the new shift state
  11409. */
  11410. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11411. if (!this.children) {
  11412. return;
  11413. }
  11414. for (var i = 0; i < this.children.length; i++) {
  11415. var row = this.children[i];
  11416. if (!row || !row.children) {
  11417. continue;
  11418. }
  11419. var rowContainer = row;
  11420. for (var j = 0; j < rowContainer.children.length; j++) {
  11421. var button = rowContainer.children[j];
  11422. if (!button || !button.children[0]) {
  11423. continue;
  11424. }
  11425. var button_tblock = button.children[0];
  11426. if (button_tblock.text === "\u21E7") {
  11427. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11428. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11429. }
  11430. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11431. }
  11432. }
  11433. };
  11434. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11435. /** Gets the input text control currently attached to the keyboard */
  11436. get: function () {
  11437. return this._currentlyConnectedInputText;
  11438. },
  11439. enumerable: true,
  11440. configurable: true
  11441. });
  11442. /**
  11443. * Connects the keyboard with an input text control
  11444. *
  11445. * @param input defines the target control
  11446. */
  11447. VirtualKeyboard.prototype.connect = function (input) {
  11448. var _this = this;
  11449. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11450. if (inputTextAlreadyConnected) {
  11451. return;
  11452. }
  11453. if (this._onKeyPressObserver === null) {
  11454. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11455. if (!_this._currentlyConnectedInputText) {
  11456. return;
  11457. }
  11458. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11459. switch (key) {
  11460. case "\u21E7":
  11461. _this.shiftState++;
  11462. if (_this.shiftState > 2) {
  11463. _this.shiftState = 0;
  11464. }
  11465. _this.applyShiftState(_this.shiftState);
  11466. return;
  11467. case "\u2190":
  11468. _this._currentlyConnectedInputText.processKey(8);
  11469. return;
  11470. case "\u21B5":
  11471. _this._currentlyConnectedInputText.processKey(13);
  11472. return;
  11473. }
  11474. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11475. if (_this.shiftState === 1) {
  11476. _this.shiftState = 0;
  11477. _this.applyShiftState(_this.shiftState);
  11478. }
  11479. });
  11480. }
  11481. this.isVisible = false;
  11482. this._currentlyConnectedInputText = input;
  11483. input._connectedVirtualKeyboard = this;
  11484. // Events hooking
  11485. var onFocusObserver = input.onFocusObservable.add(function () {
  11486. _this._currentlyConnectedInputText = input;
  11487. input._connectedVirtualKeyboard = _this;
  11488. _this.isVisible = true;
  11489. });
  11490. var onBlurObserver = input.onBlurObservable.add(function () {
  11491. input._connectedVirtualKeyboard = null;
  11492. _this._currentlyConnectedInputText = null;
  11493. _this.isVisible = false;
  11494. });
  11495. this._connectedInputTexts.push({
  11496. input: input,
  11497. onBlurObserver: onBlurObserver,
  11498. onFocusObserver: onFocusObserver
  11499. });
  11500. };
  11501. /**
  11502. * Disconnects the keyboard from connected InputText controls
  11503. *
  11504. * @param input optionally defines a target control, otherwise all are disconnected
  11505. */
  11506. VirtualKeyboard.prototype.disconnect = function (input) {
  11507. var _this = this;
  11508. if (input) {
  11509. // .find not available on IE
  11510. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11511. if (filtered.length === 1) {
  11512. this._removeConnectedInputObservables(filtered[0]);
  11513. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11514. if (this._currentlyConnectedInputText === input) {
  11515. this._currentlyConnectedInputText = null;
  11516. }
  11517. }
  11518. }
  11519. else {
  11520. this._connectedInputTexts.forEach(function (connectedInputText) {
  11521. _this._removeConnectedInputObservables(connectedInputText);
  11522. });
  11523. this._connectedInputTexts = [];
  11524. }
  11525. if (this._connectedInputTexts.length === 0) {
  11526. this._currentlyConnectedInputText = null;
  11527. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11528. this._onKeyPressObserver = null;
  11529. }
  11530. };
  11531. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11532. connectedInputText.input._connectedVirtualKeyboard = null;
  11533. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11534. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11535. };
  11536. /**
  11537. * Release all resources
  11538. */
  11539. VirtualKeyboard.prototype.dispose = function () {
  11540. _super.prototype.dispose.call(this);
  11541. this.disconnect();
  11542. };
  11543. // Statics
  11544. /**
  11545. * Creates a new keyboard using a default layout
  11546. *
  11547. * @param name defines control name
  11548. * @returns a new VirtualKeyboard
  11549. */
  11550. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11551. var returnValue = new VirtualKeyboard(name);
  11552. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11553. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11554. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11555. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11556. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11557. return returnValue;
  11558. };
  11559. return VirtualKeyboard;
  11560. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11561. /***/ }),
  11562. /***/ "./2D/index.ts":
  11563. /*!*********************!*\
  11564. !*** ./2D/index.ts ***!
  11565. \*********************/
  11566. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, name */
  11567. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11568. "use strict";
  11569. __webpack_require__.r(__webpack_exports__);
  11570. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11602. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11604. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11606. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11609. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11611. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11613. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11615. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11617. /***/ }),
  11618. /***/ "./2D/math2D.ts":
  11619. /*!**********************!*\
  11620. !*** ./2D/math2D.ts ***!
  11621. \**********************/
  11622. /*! exports provided: Vector2WithInfo, Matrix2D */
  11623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11624. "use strict";
  11625. __webpack_require__.r(__webpack_exports__);
  11626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11628. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11629. <<<<<<< HEAD
  11630. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11631. =======
  11632. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  11633. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  11634. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11635. /**
  11636. * Class used to transport Vector2 information for pointer events
  11637. */
  11638. var Vector2WithInfo = /** @class */ (function (_super) {
  11639. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11640. /**
  11641. * Creates a new Vector2WithInfo
  11642. * @param source defines the vector2 data to transport
  11643. * @param buttonIndex defines the current mouse button index
  11644. */
  11645. function Vector2WithInfo(source,
  11646. /** defines the current mouse button index */
  11647. buttonIndex) {
  11648. if (buttonIndex === void 0) { buttonIndex = 0; }
  11649. var _this = _super.call(this, source.x, source.y) || this;
  11650. _this.buttonIndex = buttonIndex;
  11651. return _this;
  11652. }
  11653. return Vector2WithInfo;
  11654. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11655. /** Class used to provide 2D matrix features */
  11656. var Matrix2D = /** @class */ (function () {
  11657. /**
  11658. * Creates a new matrix
  11659. * @param m00 defines value for (0, 0)
  11660. * @param m01 defines value for (0, 1)
  11661. * @param m10 defines value for (1, 0)
  11662. * @param m11 defines value for (1, 1)
  11663. * @param m20 defines value for (2, 0)
  11664. * @param m21 defines value for (2, 1)
  11665. */
  11666. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11667. /** Gets the internal array of 6 floats used to store matrix data */
  11668. this.m = new Float32Array(6);
  11669. this.fromValues(m00, m01, m10, m11, m20, m21);
  11670. }
  11671. /**
  11672. * Fills the matrix from direct values
  11673. * @param m00 defines value for (0, 0)
  11674. * @param m01 defines value for (0, 1)
  11675. * @param m10 defines value for (1, 0)
  11676. * @param m11 defines value for (1, 1)
  11677. * @param m20 defines value for (2, 0)
  11678. * @param m21 defines value for (2, 1)
  11679. * @returns the current modified matrix
  11680. */
  11681. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11682. this.m[0] = m00;
  11683. this.m[1] = m01;
  11684. this.m[2] = m10;
  11685. this.m[3] = m11;
  11686. this.m[4] = m20;
  11687. this.m[5] = m21;
  11688. return this;
  11689. };
  11690. /**
  11691. * Gets matrix determinant
  11692. * @returns the determinant
  11693. */
  11694. Matrix2D.prototype.determinant = function () {
  11695. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11696. };
  11697. /**
  11698. * Inverses the matrix and stores it in a target matrix
  11699. * @param result defines the target matrix
  11700. * @returns the current matrix
  11701. */
  11702. Matrix2D.prototype.invertToRef = function (result) {
  11703. var l0 = this.m[0];
  11704. var l1 = this.m[1];
  11705. var l2 = this.m[2];
  11706. var l3 = this.m[3];
  11707. var l4 = this.m[4];
  11708. var l5 = this.m[5];
  11709. var det = this.determinant();
  11710. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11711. result.m[0] = 0;
  11712. result.m[1] = 0;
  11713. result.m[2] = 0;
  11714. result.m[3] = 0;
  11715. result.m[4] = 0;
  11716. result.m[5] = 0;
  11717. return this;
  11718. }
  11719. var detDiv = 1 / det;
  11720. var det4 = l2 * l5 - l3 * l4;
  11721. var det5 = l1 * l4 - l0 * l5;
  11722. result.m[0] = l3 * detDiv;
  11723. result.m[1] = -l1 * detDiv;
  11724. result.m[2] = -l2 * detDiv;
  11725. result.m[3] = l0 * detDiv;
  11726. result.m[4] = det4 * detDiv;
  11727. result.m[5] = det5 * detDiv;
  11728. return this;
  11729. };
  11730. /**
  11731. * Multiplies the current matrix with another one
  11732. * @param other defines the second operand
  11733. * @param result defines the target matrix
  11734. * @returns the current matrix
  11735. */
  11736. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11737. var l0 = this.m[0];
  11738. var l1 = this.m[1];
  11739. var l2 = this.m[2];
  11740. var l3 = this.m[3];
  11741. var l4 = this.m[4];
  11742. var l5 = this.m[5];
  11743. var r0 = other.m[0];
  11744. var r1 = other.m[1];
  11745. var r2 = other.m[2];
  11746. var r3 = other.m[3];
  11747. var r4 = other.m[4];
  11748. var r5 = other.m[5];
  11749. result.m[0] = l0 * r0 + l1 * r2;
  11750. result.m[1] = l0 * r1 + l1 * r3;
  11751. result.m[2] = l2 * r0 + l3 * r2;
  11752. result.m[3] = l2 * r1 + l3 * r3;
  11753. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11754. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11755. return this;
  11756. };
  11757. /**
  11758. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11759. * @param x defines the x coordinate to transform
  11760. * @param y defines the x coordinate to transform
  11761. * @param result defines the target vector2
  11762. * @returns the current matrix
  11763. */
  11764. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11765. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11766. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11767. return this;
  11768. };
  11769. // Statics
  11770. /**
  11771. * Creates an identity matrix
  11772. * @returns a new matrix
  11773. */
  11774. Matrix2D.Identity = function () {
  11775. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11776. };
  11777. /**
  11778. * Creates a translation matrix and stores it in a target matrix
  11779. * @param x defines the x coordinate of the translation
  11780. * @param y defines the y coordinate of the translation
  11781. * @param result defines the target matrix
  11782. */
  11783. Matrix2D.TranslationToRef = function (x, y, result) {
  11784. result.fromValues(1, 0, 0, 1, x, y);
  11785. };
  11786. /**
  11787. * Creates a scaling matrix and stores it in a target matrix
  11788. * @param x defines the x coordinate of the scaling
  11789. * @param y defines the y coordinate of the scaling
  11790. * @param result defines the target matrix
  11791. */
  11792. Matrix2D.ScalingToRef = function (x, y, result) {
  11793. result.fromValues(x, 0, 0, y, 0, 0);
  11794. };
  11795. /**
  11796. * Creates a rotation matrix and stores it in a target matrix
  11797. * @param angle defines the rotation angle
  11798. * @param result defines the target matrix
  11799. */
  11800. Matrix2D.RotationToRef = function (angle, result) {
  11801. var s = Math.sin(angle);
  11802. var c = Math.cos(angle);
  11803. result.fromValues(c, s, -s, c, 0, 0);
  11804. };
  11805. /**
  11806. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11807. * @param tx defines the x coordinate of the translation
  11808. * @param ty defines the y coordinate of the translation
  11809. * @param angle defines the rotation angle
  11810. * @param scaleX defines the x coordinate of the scaling
  11811. * @param scaleY defines the y coordinate of the scaling
  11812. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11813. * @param result defines the target matrix
  11814. */
  11815. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11816. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11817. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11818. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11819. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11820. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11821. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11822. if (parentMatrix) {
  11823. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11824. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11825. }
  11826. else {
  11827. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11828. }
  11829. };
  11830. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11831. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11832. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11833. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11834. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11835. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11836. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11837. return Matrix2D;
  11838. }());
  11839. /***/ }),
  11840. /***/ "./2D/measure.ts":
  11841. /*!***********************!*\
  11842. !*** ./2D/measure.ts ***!
  11843. \***********************/
  11844. /*! exports provided: Measure */
  11845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11846. "use strict";
  11847. __webpack_require__.r(__webpack_exports__);
  11848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11849. <<<<<<< HEAD
  11850. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11851. =======
  11852. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  11853. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  11854. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11855. /**
  11856. * Class used to store 2D control sizes
  11857. */
  11858. var Measure = /** @class */ (function () {
  11859. /**
  11860. * Creates a new measure
  11861. * @param left defines left coordinate
  11862. * @param top defines top coordinate
  11863. * @param width defines width dimension
  11864. * @param height defines height dimension
  11865. */
  11866. function Measure(
  11867. /** defines left coordinate */
  11868. left,
  11869. /** defines top coordinate */
  11870. top,
  11871. /** defines width dimension */
  11872. width,
  11873. /** defines height dimension */
  11874. height) {
  11875. this.left = left;
  11876. this.top = top;
  11877. this.width = width;
  11878. this.height = height;
  11879. }
  11880. /**
  11881. * Copy from another measure
  11882. * @param other defines the other measure to copy from
  11883. */
  11884. Measure.prototype.copyFrom = function (other) {
  11885. this.left = other.left;
  11886. this.top = other.top;
  11887. this.width = other.width;
  11888. this.height = other.height;
  11889. };
  11890. /**
  11891. * Copy from a group of 4 floats
  11892. * @param left defines left coordinate
  11893. * @param top defines top coordinate
  11894. * @param width defines width dimension
  11895. * @param height defines height dimension
  11896. */
  11897. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11898. this.left = left;
  11899. this.top = top;
  11900. this.width = width;
  11901. this.height = height;
  11902. };
  11903. /**
  11904. * Computes the axis aligned bounding box measure for two given measures
  11905. * @param a Input measure
  11906. * @param b Input measure
  11907. * @param result the resulting bounding measure
  11908. */
  11909. Measure.CombineToRef = function (a, b, result) {
  11910. var left = Math.min(a.left, b.left);
  11911. var top = Math.min(a.top, b.top);
  11912. var right = Math.max(a.left + a.width, b.left + b.width);
  11913. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11914. result.left = left;
  11915. result.top = top;
  11916. result.width = right - left;
  11917. result.height = bottom - top;
  11918. };
  11919. /**
  11920. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11921. * @param transform the matrix to transform the measure before computing the AABB
  11922. * @param result the resulting AABB
  11923. */
  11924. Measure.prototype.transformToRef = function (transform, result) {
  11925. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11926. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11927. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11928. for (var i = 0; i < 4; i++) {
  11929. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11930. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11931. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11932. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11933. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11934. }
  11935. result.left = min.x;
  11936. result.top = min.y;
  11937. result.width = max.x - min.x;
  11938. result.height = max.y - min.y;
  11939. };
  11940. /**
  11941. * Check equality between this measure and another one
  11942. * @param other defines the other measures
  11943. * @returns true if both measures are equals
  11944. */
  11945. Measure.prototype.isEqualsTo = function (other) {
  11946. if (this.left !== other.left) {
  11947. return false;
  11948. }
  11949. if (this.top !== other.top) {
  11950. return false;
  11951. }
  11952. if (this.width !== other.width) {
  11953. return false;
  11954. }
  11955. if (this.height !== other.height) {
  11956. return false;
  11957. }
  11958. return true;
  11959. };
  11960. /**
  11961. * Creates an empty measure
  11962. * @returns a new measure
  11963. */
  11964. Measure.Empty = function () {
  11965. return new Measure(0, 0, 0, 0);
  11966. };
  11967. return Measure;
  11968. }());
  11969. /***/ }),
  11970. /***/ "./2D/multiLinePoint.ts":
  11971. /*!******************************!*\
  11972. !*** ./2D/multiLinePoint.ts ***!
  11973. \******************************/
  11974. /*! exports provided: MultiLinePoint */
  11975. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11976. "use strict";
  11977. __webpack_require__.r(__webpack_exports__);
  11978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11979. <<<<<<< HEAD
  11980. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11981. =======
  11982. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  11983. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  11984. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11985. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11986. /**
  11987. * Class used to store a point for a MultiLine object.
  11988. * The point can be pure 2D coordinates, a mesh or a control
  11989. */
  11990. var MultiLinePoint = /** @class */ (function () {
  11991. /**
  11992. * Creates a new MultiLinePoint
  11993. * @param multiLine defines the source MultiLine object
  11994. */
  11995. function MultiLinePoint(multiLine) {
  11996. this._multiLine = multiLine;
  11997. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11998. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11999. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12000. }
  12001. Object.defineProperty(MultiLinePoint.prototype, "x", {
  12002. /** Gets or sets x coordinate */
  12003. get: function () {
  12004. return this._x.toString(this._multiLine._host);
  12005. },
  12006. set: function (value) {
  12007. if (this._x.toString(this._multiLine._host) === value) {
  12008. return;
  12009. }
  12010. if (this._x.fromString(value)) {
  12011. this._multiLine._markAsDirty();
  12012. }
  12013. },
  12014. enumerable: true,
  12015. configurable: true
  12016. });
  12017. Object.defineProperty(MultiLinePoint.prototype, "y", {
  12018. /** Gets or sets y coordinate */
  12019. get: function () {
  12020. return this._y.toString(this._multiLine._host);
  12021. },
  12022. set: function (value) {
  12023. if (this._y.toString(this._multiLine._host) === value) {
  12024. return;
  12025. }
  12026. if (this._y.fromString(value)) {
  12027. this._multiLine._markAsDirty();
  12028. }
  12029. },
  12030. enumerable: true,
  12031. configurable: true
  12032. });
  12033. Object.defineProperty(MultiLinePoint.prototype, "control", {
  12034. /** Gets or sets the control associated with this point */
  12035. get: function () {
  12036. return this._control;
  12037. },
  12038. set: function (value) {
  12039. if (this._control === value) {
  12040. return;
  12041. }
  12042. if (this._control && this._controlObserver) {
  12043. this._control.onDirtyObservable.remove(this._controlObserver);
  12044. this._controlObserver = null;
  12045. }
  12046. this._control = value;
  12047. if (this._control) {
  12048. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  12049. }
  12050. this._multiLine._markAsDirty();
  12051. },
  12052. enumerable: true,
  12053. configurable: true
  12054. });
  12055. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  12056. /** Gets or sets the mesh associated with this point */
  12057. get: function () {
  12058. return this._mesh;
  12059. },
  12060. set: function (value) {
  12061. if (this._mesh === value) {
  12062. return;
  12063. }
  12064. if (this._mesh && this._meshObserver) {
  12065. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  12066. }
  12067. this._mesh = value;
  12068. if (this._mesh) {
  12069. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12070. }
  12071. this._multiLine._markAsDirty();
  12072. },
  12073. enumerable: true,
  12074. configurable: true
  12075. });
  12076. /** Resets links */
  12077. MultiLinePoint.prototype.resetLinks = function () {
  12078. this.control = null;
  12079. this.mesh = null;
  12080. };
  12081. /**
  12082. * Gets a translation vector
  12083. * @returns the translation vector
  12084. */
  12085. MultiLinePoint.prototype.translate = function () {
  12086. this._point = this._translatePoint();
  12087. return this._point;
  12088. };
  12089. MultiLinePoint.prototype._translatePoint = function () {
  12090. if (this._mesh != null) {
  12091. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12092. }
  12093. else if (this._control != null) {
  12094. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12095. }
  12096. else {
  12097. var host = this._multiLine._host;
  12098. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12099. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12100. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12101. }
  12102. };
  12103. /** Release associated resources */
  12104. MultiLinePoint.prototype.dispose = function () {
  12105. this.resetLinks();
  12106. };
  12107. return MultiLinePoint;
  12108. }());
  12109. /***/ }),
  12110. /***/ "./2D/style.ts":
  12111. /*!*********************!*\
  12112. !*** ./2D/style.ts ***!
  12113. \*********************/
  12114. /*! exports provided: Style */
  12115. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12116. "use strict";
  12117. __webpack_require__.r(__webpack_exports__);
  12118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12119. <<<<<<< HEAD
  12120. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12121. =======
  12122. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  12123. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  12124. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12125. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12126. /**
  12127. * Define a style used by control to automatically setup properties based on a template.
  12128. * Only support font related properties so far
  12129. */
  12130. var Style = /** @class */ (function () {
  12131. /**
  12132. * Creates a new style object
  12133. * @param host defines the AdvancedDynamicTexture which hosts this style
  12134. */
  12135. function Style(host) {
  12136. this._fontFamily = "Arial";
  12137. this._fontStyle = "";
  12138. this._fontWeight = "";
  12139. /** @hidden */
  12140. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12141. /**
  12142. * Observable raised when the style values are changed
  12143. */
  12144. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12145. this._host = host;
  12146. }
  12147. Object.defineProperty(Style.prototype, "fontSize", {
  12148. /**
  12149. * Gets or sets the font size
  12150. */
  12151. get: function () {
  12152. return this._fontSize.toString(this._host);
  12153. },
  12154. set: function (value) {
  12155. if (this._fontSize.toString(this._host) === value) {
  12156. return;
  12157. }
  12158. if (this._fontSize.fromString(value)) {
  12159. this.onChangedObservable.notifyObservers(this);
  12160. }
  12161. },
  12162. enumerable: true,
  12163. configurable: true
  12164. });
  12165. Object.defineProperty(Style.prototype, "fontFamily", {
  12166. /**
  12167. * Gets or sets the font family
  12168. */
  12169. get: function () {
  12170. return this._fontFamily;
  12171. },
  12172. set: function (value) {
  12173. if (this._fontFamily === value) {
  12174. return;
  12175. }
  12176. this._fontFamily = value;
  12177. this.onChangedObservable.notifyObservers(this);
  12178. },
  12179. enumerable: true,
  12180. configurable: true
  12181. });
  12182. Object.defineProperty(Style.prototype, "fontStyle", {
  12183. /**
  12184. * Gets or sets the font style
  12185. */
  12186. get: function () {
  12187. return this._fontStyle;
  12188. },
  12189. set: function (value) {
  12190. if (this._fontStyle === value) {
  12191. return;
  12192. }
  12193. this._fontStyle = value;
  12194. this.onChangedObservable.notifyObservers(this);
  12195. },
  12196. enumerable: true,
  12197. configurable: true
  12198. });
  12199. Object.defineProperty(Style.prototype, "fontWeight", {
  12200. /** Gets or sets font weight */
  12201. get: function () {
  12202. return this._fontWeight;
  12203. },
  12204. set: function (value) {
  12205. if (this._fontWeight === value) {
  12206. return;
  12207. }
  12208. this._fontWeight = value;
  12209. this.onChangedObservable.notifyObservers(this);
  12210. },
  12211. enumerable: true,
  12212. configurable: true
  12213. });
  12214. /** Dispose all associated resources */
  12215. Style.prototype.dispose = function () {
  12216. this.onChangedObservable.clear();
  12217. };
  12218. return Style;
  12219. }());
  12220. /***/ }),
  12221. /***/ "./2D/valueAndUnit.ts":
  12222. /*!****************************!*\
  12223. !*** ./2D/valueAndUnit.ts ***!
  12224. \****************************/
  12225. /*! exports provided: ValueAndUnit */
  12226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12227. "use strict";
  12228. __webpack_require__.r(__webpack_exports__);
  12229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12230. /**
  12231. * Class used to specific a value and its associated unit
  12232. */
  12233. var ValueAndUnit = /** @class */ (function () {
  12234. /**
  12235. * Creates a new ValueAndUnit
  12236. * @param value defines the value to store
  12237. * @param unit defines the unit to store
  12238. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12239. */
  12240. function ValueAndUnit(value,
  12241. /** defines the unit to store */
  12242. unit,
  12243. /** defines a boolean indicating if the value can be negative */
  12244. negativeValueAllowed) {
  12245. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12246. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12247. this.unit = unit;
  12248. this.negativeValueAllowed = negativeValueAllowed;
  12249. this._value = 1;
  12250. /**
  12251. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12252. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12253. */
  12254. this.ignoreAdaptiveScaling = false;
  12255. this._value = value;
  12256. this._originalUnit = unit;
  12257. }
  12258. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12259. /** Gets a boolean indicating if the value is a percentage */
  12260. get: function () {
  12261. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12262. },
  12263. enumerable: true,
  12264. configurable: true
  12265. });
  12266. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12267. /** Gets a boolean indicating if the value is store as pixel */
  12268. get: function () {
  12269. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12270. },
  12271. enumerable: true,
  12272. configurable: true
  12273. });
  12274. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12275. /** Gets direct internal value */
  12276. get: function () {
  12277. return this._value;
  12278. },
  12279. enumerable: true,
  12280. configurable: true
  12281. });
  12282. /**
  12283. * Gets value as pixel
  12284. * @param host defines the root host
  12285. * @param refValue defines the reference value for percentages
  12286. * @returns the value as pixel
  12287. */
  12288. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12289. if (this.isPixel) {
  12290. return this.getValue(host);
  12291. }
  12292. return this.getValue(host) * refValue;
  12293. };
  12294. /**
  12295. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12296. * @param value defines the value to store
  12297. * @param unit defines the unit to store
  12298. * @returns the current ValueAndUnit
  12299. */
  12300. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12301. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12302. this._value = value;
  12303. this.unit = unit;
  12304. return this;
  12305. };
  12306. /**
  12307. * Gets the value accordingly to its unit
  12308. * @param host defines the root host
  12309. * @returns the value
  12310. */
  12311. ValueAndUnit.prototype.getValue = function (host) {
  12312. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12313. var width = 0;
  12314. var height = 0;
  12315. if (host.idealWidth) {
  12316. width = (this._value * host.getSize().width) / host.idealWidth;
  12317. }
  12318. if (host.idealHeight) {
  12319. height = (this._value * host.getSize().height) / host.idealHeight;
  12320. }
  12321. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12322. return window.innerWidth < window.innerHeight ? width : height;
  12323. }
  12324. if (host.idealWidth) { // horizontal
  12325. return width;
  12326. }
  12327. if (host.idealHeight) { // vertical
  12328. return height;
  12329. }
  12330. }
  12331. return this._value;
  12332. };
  12333. /**
  12334. * Gets a string representation of the value
  12335. * @param host defines the root host
  12336. * @param decimals defines an optional number of decimals to display
  12337. * @returns a string
  12338. */
  12339. ValueAndUnit.prototype.toString = function (host, decimals) {
  12340. switch (this.unit) {
  12341. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12342. var percentage = this.getValue(host) * 100;
  12343. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12344. case ValueAndUnit.UNITMODE_PIXEL:
  12345. var pixels = this.getValue(host);
  12346. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12347. }
  12348. return this.unit.toString();
  12349. };
  12350. /**
  12351. * Store a value parsed from a string
  12352. * @param source defines the source string
  12353. * @returns true if the value was successfully parsed
  12354. */
  12355. ValueAndUnit.prototype.fromString = function (source) {
  12356. var match = ValueAndUnit._Regex.exec(source.toString());
  12357. if (!match || match.length === 0) {
  12358. return false;
  12359. }
  12360. var sourceValue = parseFloat(match[1]);
  12361. var sourceUnit = this._originalUnit;
  12362. if (!this.negativeValueAllowed) {
  12363. if (sourceValue < 0) {
  12364. sourceValue = 0;
  12365. }
  12366. }
  12367. if (match.length === 4) {
  12368. switch (match[3]) {
  12369. case "px":
  12370. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12371. break;
  12372. case "%":
  12373. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12374. sourceValue /= 100.0;
  12375. break;
  12376. }
  12377. }
  12378. if (sourceValue === this._value && sourceUnit === this.unit) {
  12379. return false;
  12380. }
  12381. this._value = sourceValue;
  12382. this.unit = sourceUnit;
  12383. return true;
  12384. };
  12385. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12386. /** UNITMODE_PERCENTAGE */
  12387. get: function () {
  12388. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12389. },
  12390. enumerable: true,
  12391. configurable: true
  12392. });
  12393. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12394. /** UNITMODE_PIXEL */
  12395. get: function () {
  12396. return ValueAndUnit._UNITMODE_PIXEL;
  12397. },
  12398. enumerable: true,
  12399. configurable: true
  12400. });
  12401. // Static
  12402. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12403. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12404. ValueAndUnit._UNITMODE_PIXEL = 1;
  12405. return ValueAndUnit;
  12406. }());
  12407. /***/ }),
  12408. /***/ "./3D/controls/abstractButton3D.ts":
  12409. /*!*****************************************!*\
  12410. !*** ./3D/controls/abstractButton3D.ts ***!
  12411. \*****************************************/
  12412. /*! exports provided: AbstractButton3D */
  12413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12414. "use strict";
  12415. __webpack_require__.r(__webpack_exports__);
  12416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12417. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12418. <<<<<<< HEAD
  12419. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12420. =======
  12421. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/tools");
  12422. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  12423. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12424. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12425. /**
  12426. * Class used as a root to all buttons
  12427. */
  12428. var AbstractButton3D = /** @class */ (function (_super) {
  12429. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12430. /**
  12431. * Creates a new button
  12432. * @param name defines the control name
  12433. */
  12434. function AbstractButton3D(name) {
  12435. return _super.call(this, name) || this;
  12436. }
  12437. AbstractButton3D.prototype._getTypeName = function () {
  12438. return "AbstractButton3D";
  12439. };
  12440. // Mesh association
  12441. AbstractButton3D.prototype._createNode = function (scene) {
  12442. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12443. };
  12444. return AbstractButton3D;
  12445. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12446. /***/ }),
  12447. /***/ "./3D/controls/button3D.ts":
  12448. /*!*********************************!*\
  12449. !*** ./3D/controls/button3D.ts ***!
  12450. \*********************************/
  12451. /*! exports provided: Button3D */
  12452. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12453. "use strict";
  12454. __webpack_require__.r(__webpack_exports__);
  12455. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12456. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12457. <<<<<<< HEAD
  12458. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  12459. =======
  12460. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  12461. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  12462. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12463. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12464. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12465. /**
  12466. * Class used to create a button in 3D
  12467. */
  12468. var Button3D = /** @class */ (function (_super) {
  12469. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12470. /**
  12471. * Creates a new button
  12472. * @param name defines the control name
  12473. */
  12474. function Button3D(name) {
  12475. var _this = _super.call(this, name) || this;
  12476. _this._contentResolution = 512;
  12477. _this._contentScaleRatio = 2;
  12478. // Default animations
  12479. _this.pointerEnterAnimation = function () {
  12480. if (!_this.mesh) {
  12481. return;
  12482. }
  12483. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12484. };
  12485. _this.pointerOutAnimation = function () {
  12486. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12487. };
  12488. _this.pointerDownAnimation = function () {
  12489. if (!_this.mesh) {
  12490. return;
  12491. }
  12492. _this.mesh.scaling.scaleInPlace(0.95);
  12493. };
  12494. _this.pointerUpAnimation = function () {
  12495. if (!_this.mesh) {
  12496. return;
  12497. }
  12498. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12499. };
  12500. return _this;
  12501. }
  12502. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12503. /**
  12504. * Gets or sets the texture resolution used to render content (512 by default)
  12505. */
  12506. get: function () {
  12507. return this._contentResolution;
  12508. },
  12509. set: function (value) {
  12510. if (this._contentResolution === value) {
  12511. return;
  12512. }
  12513. this._contentResolution = value;
  12514. this._resetContent();
  12515. },
  12516. enumerable: true,
  12517. configurable: true
  12518. });
  12519. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12520. /**
  12521. * Gets or sets the texture scale ratio used to render content (2 by default)
  12522. */
  12523. get: function () {
  12524. return this._contentScaleRatio;
  12525. },
  12526. set: function (value) {
  12527. if (this._contentScaleRatio === value) {
  12528. return;
  12529. }
  12530. this._contentScaleRatio = value;
  12531. this._resetContent();
  12532. },
  12533. enumerable: true,
  12534. configurable: true
  12535. });
  12536. Button3D.prototype._disposeFacadeTexture = function () {
  12537. if (this._facadeTexture) {
  12538. this._facadeTexture.dispose();
  12539. this._facadeTexture = null;
  12540. }
  12541. };
  12542. Button3D.prototype._resetContent = function () {
  12543. this._disposeFacadeTexture();
  12544. this.content = this._content;
  12545. };
  12546. Object.defineProperty(Button3D.prototype, "content", {
  12547. /**
  12548. * Gets or sets the GUI 2D content used to display the button's facade
  12549. */
  12550. get: function () {
  12551. return this._content;
  12552. },
  12553. set: function (value) {
  12554. this._content = value;
  12555. if (!this._host || !this._host.utilityLayer) {
  12556. return;
  12557. }
  12558. if (!this._facadeTexture) {
  12559. 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);
  12560. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12561. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12562. this._facadeTexture.premulAlpha = true;
  12563. }
  12564. this._facadeTexture.addControl(value);
  12565. this._applyFacade(this._facadeTexture);
  12566. },
  12567. enumerable: true,
  12568. configurable: true
  12569. });
  12570. /**
  12571. * Apply the facade texture (created from the content property).
  12572. * This function can be overloaded by child classes
  12573. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12574. */
  12575. Button3D.prototype._applyFacade = function (facadeTexture) {
  12576. this._currentMaterial.emissiveTexture = facadeTexture;
  12577. };
  12578. Button3D.prototype._getTypeName = function () {
  12579. return "Button3D";
  12580. };
  12581. // Mesh association
  12582. Button3D.prototype._createNode = function (scene) {
  12583. var faceUV = new Array(6);
  12584. for (var i = 0; i < 6; i++) {
  12585. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12586. }
  12587. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12588. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12589. width: 1.0,
  12590. height: 1.0,
  12591. depth: 0.08,
  12592. faceUV: faceUV
  12593. }, scene);
  12594. return mesh;
  12595. };
  12596. Button3D.prototype._affectMaterial = function (mesh) {
  12597. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12598. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12599. mesh.material = material;
  12600. this._currentMaterial = material;
  12601. this._resetContent();
  12602. };
  12603. /**
  12604. * Releases all associated resources
  12605. */
  12606. Button3D.prototype.dispose = function () {
  12607. _super.prototype.dispose.call(this);
  12608. this._disposeFacadeTexture();
  12609. if (this._currentMaterial) {
  12610. this._currentMaterial.dispose();
  12611. }
  12612. };
  12613. return Button3D;
  12614. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12615. /***/ }),
  12616. /***/ "./3D/controls/container3D.ts":
  12617. /*!************************************!*\
  12618. !*** ./3D/controls/container3D.ts ***!
  12619. \************************************/
  12620. /*! exports provided: Container3D */
  12621. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12622. "use strict";
  12623. __webpack_require__.r(__webpack_exports__);
  12624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12625. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12626. <<<<<<< HEAD
  12627. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12628. =======
  12629. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/tools");
  12630. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  12631. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12632. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12633. /**
  12634. * Class used to create containers for controls
  12635. */
  12636. var Container3D = /** @class */ (function (_super) {
  12637. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12638. /**
  12639. * Creates a new container
  12640. * @param name defines the container name
  12641. */
  12642. function Container3D(name) {
  12643. var _this = _super.call(this, name) || this;
  12644. _this._blockLayout = false;
  12645. /**
  12646. * Gets the list of child controls
  12647. */
  12648. _this._children = new Array();
  12649. return _this;
  12650. }
  12651. Object.defineProperty(Container3D.prototype, "children", {
  12652. /**
  12653. * Gets the list of child controls
  12654. */
  12655. get: function () {
  12656. return this._children;
  12657. },
  12658. enumerable: true,
  12659. configurable: true
  12660. });
  12661. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12662. /**
  12663. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12664. * This is helpful to optimize layout operation when adding multiple children in a row
  12665. */
  12666. get: function () {
  12667. return this._blockLayout;
  12668. },
  12669. set: function (value) {
  12670. if (this._blockLayout === value) {
  12671. return;
  12672. }
  12673. this._blockLayout = value;
  12674. if (!this._blockLayout) {
  12675. this._arrangeChildren();
  12676. }
  12677. },
  12678. enumerable: true,
  12679. configurable: true
  12680. });
  12681. /**
  12682. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12683. * @returns the current container
  12684. */
  12685. Container3D.prototype.updateLayout = function () {
  12686. this._arrangeChildren();
  12687. return this;
  12688. };
  12689. /**
  12690. * Gets a boolean indicating if the given control is in the children of this control
  12691. * @param control defines the control to check
  12692. * @returns true if the control is in the child list
  12693. */
  12694. Container3D.prototype.containsControl = function (control) {
  12695. return this._children.indexOf(control) !== -1;
  12696. };
  12697. /**
  12698. * Adds a control to the children of this control
  12699. * @param control defines the control to add
  12700. * @returns the current container
  12701. */
  12702. Container3D.prototype.addControl = function (control) {
  12703. var index = this._children.indexOf(control);
  12704. if (index !== -1) {
  12705. return this;
  12706. }
  12707. control.parent = this;
  12708. control._host = this._host;
  12709. this._children.push(control);
  12710. if (this._host.utilityLayer) {
  12711. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12712. if (control.node) {
  12713. control.node.parent = this.node;
  12714. }
  12715. if (!this.blockLayout) {
  12716. this._arrangeChildren();
  12717. }
  12718. }
  12719. return this;
  12720. };
  12721. /**
  12722. * This function will be called everytime a new control is added
  12723. */
  12724. Container3D.prototype._arrangeChildren = function () {
  12725. };
  12726. Container3D.prototype._createNode = function (scene) {
  12727. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12728. };
  12729. /**
  12730. * Removes a control from the children of this control
  12731. * @param control defines the control to remove
  12732. * @returns the current container
  12733. */
  12734. Container3D.prototype.removeControl = function (control) {
  12735. var index = this._children.indexOf(control);
  12736. if (index !== -1) {
  12737. this._children.splice(index, 1);
  12738. control.parent = null;
  12739. control._disposeNode();
  12740. }
  12741. return this;
  12742. };
  12743. Container3D.prototype._getTypeName = function () {
  12744. return "Container3D";
  12745. };
  12746. /**
  12747. * Releases all associated resources
  12748. */
  12749. Container3D.prototype.dispose = function () {
  12750. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12751. var control = _a[_i];
  12752. control.dispose();
  12753. }
  12754. this._children = [];
  12755. _super.prototype.dispose.call(this);
  12756. };
  12757. /** Control rotation will remain unchanged */
  12758. Container3D.UNSET_ORIENTATION = 0;
  12759. /** Control will rotate to make it look at sphere central axis */
  12760. Container3D.FACEORIGIN_ORIENTATION = 1;
  12761. /** Control will rotate to make it look back at sphere central axis */
  12762. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12763. /** Control will rotate to look at z axis (0, 0, 1) */
  12764. Container3D.FACEFORWARD_ORIENTATION = 3;
  12765. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12766. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12767. return Container3D;
  12768. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12769. /***/ }),
  12770. /***/ "./3D/controls/control3D.ts":
  12771. /*!**********************************!*\
  12772. !*** ./3D/controls/control3D.ts ***!
  12773. \**********************************/
  12774. /*! exports provided: Control3D */
  12775. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12776. "use strict";
  12777. __webpack_require__.r(__webpack_exports__);
  12778. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12779. <<<<<<< HEAD
  12780. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12781. =======
  12782. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  12783. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  12784. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12785. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12786. /**
  12787. * Class used as base class for controls
  12788. */
  12789. var Control3D = /** @class */ (function () {
  12790. /**
  12791. * Creates a new control
  12792. * @param name defines the control name
  12793. */
  12794. function Control3D(
  12795. /** Defines the control name */
  12796. name) {
  12797. this.name = name;
  12798. this._downCount = 0;
  12799. this._enterCount = -1;
  12800. this._downPointerIds = {};
  12801. this._isVisible = true;
  12802. /**
  12803. * An event triggered when the pointer move over the control
  12804. */
  12805. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12806. /**
  12807. * An event triggered when the pointer move out of the control
  12808. */
  12809. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12810. /**
  12811. * An event triggered when the pointer taps the control
  12812. */
  12813. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12814. /**
  12815. * An event triggered when pointer is up
  12816. */
  12817. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12818. /**
  12819. * An event triggered when a control is clicked on (with a mouse)
  12820. */
  12821. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12822. /**
  12823. * An event triggered when pointer enters the control
  12824. */
  12825. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12826. // Behaviors
  12827. this._behaviors = new Array();
  12828. }
  12829. Object.defineProperty(Control3D.prototype, "position", {
  12830. /** Gets or sets the control position in world space */
  12831. get: function () {
  12832. if (!this._node) {
  12833. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12834. }
  12835. return this._node.position;
  12836. },
  12837. set: function (value) {
  12838. if (!this._node) {
  12839. return;
  12840. }
  12841. this._node.position = value;
  12842. },
  12843. enumerable: true,
  12844. configurable: true
  12845. });
  12846. Object.defineProperty(Control3D.prototype, "scaling", {
  12847. /** Gets or sets the control scaling in world space */
  12848. get: function () {
  12849. if (!this._node) {
  12850. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12851. }
  12852. return this._node.scaling;
  12853. },
  12854. set: function (value) {
  12855. if (!this._node) {
  12856. return;
  12857. }
  12858. this._node.scaling = value;
  12859. },
  12860. enumerable: true,
  12861. configurable: true
  12862. });
  12863. Object.defineProperty(Control3D.prototype, "behaviors", {
  12864. /**
  12865. * Gets the list of attached behaviors
  12866. * @see http://doc.babylonjs.com/features/behaviour
  12867. */
  12868. get: function () {
  12869. return this._behaviors;
  12870. },
  12871. enumerable: true,
  12872. configurable: true
  12873. });
  12874. /**
  12875. * Attach a behavior to the control
  12876. * @see http://doc.babylonjs.com/features/behaviour
  12877. * @param behavior defines the behavior to attach
  12878. * @returns the current control
  12879. */
  12880. Control3D.prototype.addBehavior = function (behavior) {
  12881. var _this = this;
  12882. var index = this._behaviors.indexOf(behavior);
  12883. if (index !== -1) {
  12884. return this;
  12885. }
  12886. behavior.init();
  12887. var scene = this._host.scene;
  12888. if (scene.isLoading) {
  12889. // We defer the attach when the scene will be loaded
  12890. scene.onDataLoadedObservable.addOnce(function () {
  12891. behavior.attach(_this);
  12892. });
  12893. }
  12894. else {
  12895. behavior.attach(this);
  12896. }
  12897. this._behaviors.push(behavior);
  12898. return this;
  12899. };
  12900. /**
  12901. * Remove an attached behavior
  12902. * @see http://doc.babylonjs.com/features/behaviour
  12903. * @param behavior defines the behavior to attach
  12904. * @returns the current control
  12905. */
  12906. Control3D.prototype.removeBehavior = function (behavior) {
  12907. var index = this._behaviors.indexOf(behavior);
  12908. if (index === -1) {
  12909. return this;
  12910. }
  12911. this._behaviors[index].detach();
  12912. this._behaviors.splice(index, 1);
  12913. return this;
  12914. };
  12915. /**
  12916. * Gets an attached behavior by name
  12917. * @param name defines the name of the behavior to look for
  12918. * @see http://doc.babylonjs.com/features/behaviour
  12919. * @returns null if behavior was not found else the requested behavior
  12920. */
  12921. Control3D.prototype.getBehaviorByName = function (name) {
  12922. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12923. var behavior = _a[_i];
  12924. if (behavior.name === name) {
  12925. return behavior;
  12926. }
  12927. }
  12928. return null;
  12929. };
  12930. Object.defineProperty(Control3D.prototype, "isVisible", {
  12931. /** Gets or sets a boolean indicating if the control is visible */
  12932. get: function () {
  12933. return this._isVisible;
  12934. },
  12935. set: function (value) {
  12936. if (this._isVisible === value) {
  12937. return;
  12938. }
  12939. this._isVisible = value;
  12940. var mesh = this.mesh;
  12941. if (mesh) {
  12942. mesh.setEnabled(value);
  12943. }
  12944. },
  12945. enumerable: true,
  12946. configurable: true
  12947. });
  12948. Object.defineProperty(Control3D.prototype, "typeName", {
  12949. /**
  12950. * Gets a string representing the class name
  12951. */
  12952. get: function () {
  12953. return this._getTypeName();
  12954. },
  12955. enumerable: true,
  12956. configurable: true
  12957. });
  12958. /**
  12959. * Get the current class name of the control.
  12960. * @returns current class name
  12961. */
  12962. Control3D.prototype.getClassName = function () {
  12963. return this._getTypeName();
  12964. };
  12965. Control3D.prototype._getTypeName = function () {
  12966. return "Control3D";
  12967. };
  12968. Object.defineProperty(Control3D.prototype, "node", {
  12969. /**
  12970. * Gets the transform node used by this control
  12971. */
  12972. get: function () {
  12973. return this._node;
  12974. },
  12975. enumerable: true,
  12976. configurable: true
  12977. });
  12978. Object.defineProperty(Control3D.prototype, "mesh", {
  12979. /**
  12980. * Gets the mesh used to render this control
  12981. */
  12982. get: function () {
  12983. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12984. return this._node;
  12985. }
  12986. return null;
  12987. },
  12988. enumerable: true,
  12989. configurable: true
  12990. });
  12991. /**
  12992. * Link the control as child of the given node
  12993. * @param node defines the node to link to. Use null to unlink the control
  12994. * @returns the current control
  12995. */
  12996. Control3D.prototype.linkToTransformNode = function (node) {
  12997. if (this._node) {
  12998. this._node.parent = node;
  12999. }
  13000. return this;
  13001. };
  13002. /** @hidden **/
  13003. Control3D.prototype._prepareNode = function (scene) {
  13004. if (!this._node) {
  13005. this._node = this._createNode(scene);
  13006. if (!this.node) {
  13007. return;
  13008. }
  13009. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  13010. this._node.position = this.position;
  13011. this._node.scaling = this.scaling;
  13012. var mesh = this.mesh;
  13013. if (mesh) {
  13014. mesh.isPickable = true;
  13015. this._affectMaterial(mesh);
  13016. }
  13017. }
  13018. };
  13019. /**
  13020. * Node creation.
  13021. * Can be overriden by children
  13022. * @param scene defines the scene where the node must be attached
  13023. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  13024. */
  13025. Control3D.prototype._createNode = function (scene) {
  13026. // Do nothing by default
  13027. return null;
  13028. };
  13029. /**
  13030. * Affect a material to the given mesh
  13031. * @param mesh defines the mesh which will represent the control
  13032. */
  13033. Control3D.prototype._affectMaterial = function (mesh) {
  13034. mesh.material = null;
  13035. };
  13036. // Pointers
  13037. /** @hidden */
  13038. Control3D.prototype._onPointerMove = function (target, coordinates) {
  13039. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  13040. };
  13041. /** @hidden */
  13042. Control3D.prototype._onPointerEnter = function (target) {
  13043. if (this._enterCount > 0) {
  13044. return false;
  13045. }
  13046. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  13047. this._enterCount = 0;
  13048. }
  13049. this._enterCount++;
  13050. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  13051. if (this.pointerEnterAnimation) {
  13052. this.pointerEnterAnimation();
  13053. }
  13054. return true;
  13055. };
  13056. /** @hidden */
  13057. Control3D.prototype._onPointerOut = function (target) {
  13058. this._enterCount = 0;
  13059. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  13060. if (this.pointerOutAnimation) {
  13061. this.pointerOutAnimation();
  13062. }
  13063. };
  13064. /** @hidden */
  13065. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  13066. if (this._downCount !== 0) {
  13067. this._downCount++;
  13068. return false;
  13069. }
  13070. this._downCount++;
  13071. this._downPointerIds[pointerId] = true;
  13072. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13073. if (this.pointerDownAnimation) {
  13074. this.pointerDownAnimation();
  13075. }
  13076. return true;
  13077. };
  13078. /** @hidden */
  13079. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  13080. this._downCount--;
  13081. delete this._downPointerIds[pointerId];
  13082. if (this._downCount < 0) {
  13083. // Handle if forcePointerUp was called prior to this
  13084. this._downCount = 0;
  13085. return;
  13086. }
  13087. if (this._downCount == 0) {
  13088. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  13089. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13090. }
  13091. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13092. if (this.pointerUpAnimation) {
  13093. this.pointerUpAnimation();
  13094. }
  13095. }
  13096. };
  13097. /** @hidden */
  13098. Control3D.prototype.forcePointerUp = function (pointerId) {
  13099. if (pointerId === void 0) { pointerId = null; }
  13100. if (pointerId !== null) {
  13101. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13102. }
  13103. else {
  13104. for (var key in this._downPointerIds) {
  13105. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13106. }
  13107. if (this._downCount > 0) {
  13108. this._downCount = 1;
  13109. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13110. }
  13111. }
  13112. };
  13113. /** @hidden */
  13114. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13115. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13116. this._onPointerMove(this, pickedPoint);
  13117. var previousControlOver = this._host._lastControlOver[pointerId];
  13118. if (previousControlOver && previousControlOver !== this) {
  13119. previousControlOver._onPointerOut(this);
  13120. }
  13121. if (previousControlOver !== this) {
  13122. this._onPointerEnter(this);
  13123. }
  13124. this._host._lastControlOver[pointerId] = this;
  13125. return true;
  13126. }
  13127. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13128. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13129. this._host._lastControlDown[pointerId] = this;
  13130. this._host._lastPickedControl = this;
  13131. return true;
  13132. }
  13133. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13134. if (this._host._lastControlDown[pointerId]) {
  13135. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13136. }
  13137. delete this._host._lastControlDown[pointerId];
  13138. return true;
  13139. }
  13140. return false;
  13141. };
  13142. /** @hidden */
  13143. Control3D.prototype._disposeNode = function () {
  13144. if (this._node) {
  13145. this._node.dispose();
  13146. this._node = null;
  13147. }
  13148. };
  13149. /**
  13150. * Releases all associated resources
  13151. */
  13152. Control3D.prototype.dispose = function () {
  13153. this.onPointerDownObservable.clear();
  13154. this.onPointerEnterObservable.clear();
  13155. this.onPointerMoveObservable.clear();
  13156. this.onPointerOutObservable.clear();
  13157. this.onPointerUpObservable.clear();
  13158. this.onPointerClickObservable.clear();
  13159. this._disposeNode();
  13160. // Behaviors
  13161. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13162. var behavior = _a[_i];
  13163. behavior.detach();
  13164. }
  13165. };
  13166. return Control3D;
  13167. }());
  13168. /***/ }),
  13169. /***/ "./3D/controls/cylinderPanel.ts":
  13170. /*!**************************************!*\
  13171. !*** ./3D/controls/cylinderPanel.ts ***!
  13172. \**************************************/
  13173. /*! exports provided: CylinderPanel */
  13174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13175. "use strict";
  13176. __webpack_require__.r(__webpack_exports__);
  13177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13178. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13179. <<<<<<< HEAD
  13180. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13181. =======
  13182. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13183. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  13184. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13185. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13186. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13187. /**
  13188. * Class used to create a container panel deployed on the surface of a cylinder
  13189. */
  13190. var CylinderPanel = /** @class */ (function (_super) {
  13191. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  13192. function CylinderPanel() {
  13193. var _this = _super !== null && _super.apply(this, arguments) || this;
  13194. _this._radius = 5.0;
  13195. return _this;
  13196. }
  13197. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13198. /**
  13199. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13200. */
  13201. get: function () {
  13202. return this._radius;
  13203. },
  13204. set: function (value) {
  13205. var _this = this;
  13206. if (this._radius === value) {
  13207. return;
  13208. }
  13209. this._radius = value;
  13210. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13211. _this._arrangeChildren();
  13212. });
  13213. },
  13214. enumerable: true,
  13215. configurable: true
  13216. });
  13217. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13218. var mesh = control.mesh;
  13219. if (!mesh) {
  13220. return;
  13221. }
  13222. var newPos = this._cylindricalMapping(nodePosition);
  13223. control.position = newPos;
  13224. switch (this.orientation) {
  13225. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13226. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13227. break;
  13228. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13229. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13230. break;
  13231. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13232. break;
  13233. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13234. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13235. break;
  13236. }
  13237. };
  13238. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13239. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13240. var yAngle = (source.x / this._radius);
  13241. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13242. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13243. };
  13244. return CylinderPanel;
  13245. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13246. /***/ }),
  13247. /***/ "./3D/controls/holographicButton.ts":
  13248. /*!******************************************!*\
  13249. !*** ./3D/controls/holographicButton.ts ***!
  13250. \******************************************/
  13251. /*! exports provided: HolographicButton */
  13252. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13253. "use strict";
  13254. __webpack_require__.r(__webpack_exports__);
  13255. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13256. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13257. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13258. <<<<<<< HEAD
  13259. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13260. =======
  13261. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  13262. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  13263. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13264. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13265. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13266. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13267. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13268. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13269. /**
  13270. * Class used to create a holographic button in 3D
  13271. */
  13272. var HolographicButton = /** @class */ (function (_super) {
  13273. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13274. /**
  13275. * Creates a new button
  13276. * @param name defines the control name
  13277. */
  13278. function HolographicButton(name, shareMaterials) {
  13279. if (shareMaterials === void 0) { shareMaterials = true; }
  13280. var _this = _super.call(this, name) || this;
  13281. _this._shareMaterials = true;
  13282. _this._shareMaterials = shareMaterials;
  13283. // Default animations
  13284. _this.pointerEnterAnimation = function () {
  13285. if (!_this.mesh) {
  13286. return;
  13287. }
  13288. _this._frontPlate.setEnabled(true);
  13289. };
  13290. _this.pointerOutAnimation = function () {
  13291. if (!_this.mesh) {
  13292. return;
  13293. }
  13294. _this._frontPlate.setEnabled(false);
  13295. };
  13296. return _this;
  13297. }
  13298. HolographicButton.prototype._disposeTooltip = function () {
  13299. this._tooltipFade = null;
  13300. if (this._tooltipTextBlock) {
  13301. this._tooltipTextBlock.dispose();
  13302. }
  13303. if (this._tooltipTexture) {
  13304. this._tooltipTexture.dispose();
  13305. }
  13306. if (this._tooltipMesh) {
  13307. this._tooltipMesh.dispose();
  13308. }
  13309. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13310. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13311. };
  13312. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13313. get: function () {
  13314. if (this._tooltipTextBlock) {
  13315. return this._tooltipTextBlock.text;
  13316. }
  13317. return null;
  13318. },
  13319. /**
  13320. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13321. */
  13322. set: function (text) {
  13323. var _this = this;
  13324. if (!text) {
  13325. this._disposeTooltip();
  13326. return;
  13327. }
  13328. if (!this._tooltipFade) {
  13329. // Create tooltip with mesh and text
  13330. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13331. var tooltipBackground = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  13332. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13333. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13334. tooltipBackground.material = mat;
  13335. tooltipBackground.isPickable = false;
  13336. this._tooltipMesh.addChild(tooltipBackground);
  13337. tooltipBackground.position.z = 0.05;
  13338. this._tooltipMesh.scaling.y = 1 / 3;
  13339. this._tooltipMesh.position.y = 0.7;
  13340. this._tooltipMesh.position.z = -0.15;
  13341. this._tooltipMesh.isPickable = false;
  13342. this._tooltipMesh.parent = this._backPlate;
  13343. // Create text texture for the tooltip
  13344. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13345. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13346. this._tooltipTextBlock.scaleY = 3;
  13347. this._tooltipTextBlock.color = "white";
  13348. this._tooltipTextBlock.fontSize = 130;
  13349. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13350. // Add hover action to tooltip
  13351. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13352. this._tooltipFade.delay = 500;
  13353. this._tooltipMesh.addBehavior(this._tooltipFade);
  13354. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13355. if (_this._tooltipFade) {
  13356. _this._tooltipFade.fadeIn(true);
  13357. }
  13358. });
  13359. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13360. if (_this._tooltipFade) {
  13361. _this._tooltipFade.fadeIn(false);
  13362. }
  13363. });
  13364. }
  13365. if (this._tooltipTextBlock) {
  13366. this._tooltipTextBlock.text = text;
  13367. }
  13368. },
  13369. enumerable: true,
  13370. configurable: true
  13371. });
  13372. Object.defineProperty(HolographicButton.prototype, "text", {
  13373. /**
  13374. * Gets or sets text for the button
  13375. */
  13376. get: function () {
  13377. return this._text;
  13378. },
  13379. set: function (value) {
  13380. if (this._text === value) {
  13381. return;
  13382. }
  13383. this._text = value;
  13384. this._rebuildContent();
  13385. },
  13386. enumerable: true,
  13387. configurable: true
  13388. });
  13389. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13390. /**
  13391. * Gets or sets the image url for the button
  13392. */
  13393. get: function () {
  13394. return this._imageUrl;
  13395. },
  13396. set: function (value) {
  13397. if (this._imageUrl === value) {
  13398. return;
  13399. }
  13400. this._imageUrl = value;
  13401. this._rebuildContent();
  13402. },
  13403. enumerable: true,
  13404. configurable: true
  13405. });
  13406. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13407. /**
  13408. * Gets the back material used by this button
  13409. */
  13410. get: function () {
  13411. return this._backMaterial;
  13412. },
  13413. enumerable: true,
  13414. configurable: true
  13415. });
  13416. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13417. /**
  13418. * Gets the front material used by this button
  13419. */
  13420. get: function () {
  13421. return this._frontMaterial;
  13422. },
  13423. enumerable: true,
  13424. configurable: true
  13425. });
  13426. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13427. /**
  13428. * Gets the plate material used by this button
  13429. */
  13430. get: function () {
  13431. return this._plateMaterial;
  13432. },
  13433. enumerable: true,
  13434. configurable: true
  13435. });
  13436. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13437. /**
  13438. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13439. */
  13440. get: function () {
  13441. return this._shareMaterials;
  13442. },
  13443. enumerable: true,
  13444. configurable: true
  13445. });
  13446. HolographicButton.prototype._getTypeName = function () {
  13447. return "HolographicButton";
  13448. };
  13449. HolographicButton.prototype._rebuildContent = function () {
  13450. this._disposeFacadeTexture();
  13451. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13452. panel.isVertical = true;
  13453. if (this._imageUrl) {
  13454. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13455. image.source = this._imageUrl;
  13456. image.paddingTop = "40px";
  13457. image.height = "180px";
  13458. image.width = "100px";
  13459. image.paddingBottom = "40px";
  13460. panel.addControl(image);
  13461. }
  13462. if (this._text) {
  13463. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13464. text.text = this._text;
  13465. text.color = "white";
  13466. text.height = "30px";
  13467. text.fontSize = 24;
  13468. panel.addControl(text);
  13469. }
  13470. if (this._frontPlate) {
  13471. this.content = panel;
  13472. }
  13473. };
  13474. // Mesh association
  13475. HolographicButton.prototype._createNode = function (scene) {
  13476. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13477. width: 1.0,
  13478. height: 1.0,
  13479. depth: 0.08
  13480. }, scene);
  13481. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13482. width: 1.0,
  13483. height: 1.0,
  13484. depth: 0.08
  13485. }, scene);
  13486. this._frontPlate.parent = this._backPlate;
  13487. this._frontPlate.position.z = -0.08;
  13488. this._frontPlate.isPickable = false;
  13489. this._frontPlate.setEnabled(false);
  13490. this._textPlate = _super.prototype._createNode.call(this, scene);
  13491. this._textPlate.parent = this._backPlate;
  13492. this._textPlate.position.z = -0.08;
  13493. this._textPlate.isPickable = false;
  13494. return this._backPlate;
  13495. };
  13496. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13497. this._plateMaterial.emissiveTexture = facadeTexture;
  13498. this._plateMaterial.opacityTexture = facadeTexture;
  13499. };
  13500. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13501. var _this = this;
  13502. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13503. this._backMaterial.renderHoverLight = true;
  13504. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13505. if (pickedPoint) {
  13506. _this._backMaterial.hoverPosition = pickedPoint;
  13507. _this._backMaterial.hoverColor.a = 1.0;
  13508. }
  13509. else {
  13510. _this._backMaterial.hoverColor.a = 0;
  13511. }
  13512. });
  13513. };
  13514. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13515. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13516. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13517. this._frontMaterial.alpha = 0.5; // Additive
  13518. this._frontMaterial.renderBorders = true;
  13519. };
  13520. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13521. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13522. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13523. };
  13524. HolographicButton.prototype._affectMaterial = function (mesh) {
  13525. // Back
  13526. if (this._shareMaterials) {
  13527. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13528. this._createBackMaterial(mesh);
  13529. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13530. }
  13531. else {
  13532. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13533. }
  13534. // Front
  13535. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13536. this._createFrontMaterial(mesh);
  13537. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13538. }
  13539. else {
  13540. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13541. }
  13542. }
  13543. else {
  13544. this._createBackMaterial(mesh);
  13545. this._createFrontMaterial(mesh);
  13546. }
  13547. this._createPlateMaterial(mesh);
  13548. this._backPlate.material = this._backMaterial;
  13549. this._frontPlate.material = this._frontMaterial;
  13550. this._textPlate.material = this._plateMaterial;
  13551. this._rebuildContent();
  13552. };
  13553. /**
  13554. * Releases all associated resources
  13555. */
  13556. HolographicButton.prototype.dispose = function () {
  13557. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13558. this._disposeTooltip();
  13559. if (!this.shareMaterials) {
  13560. this._backMaterial.dispose();
  13561. this._frontMaterial.dispose();
  13562. this._plateMaterial.dispose();
  13563. if (this._pickedPointObserver) {
  13564. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13565. this._pickedPointObserver = null;
  13566. }
  13567. }
  13568. };
  13569. return HolographicButton;
  13570. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13571. /***/ }),
  13572. /***/ "./3D/controls/index.ts":
  13573. /*!******************************!*\
  13574. !*** ./3D/controls/index.ts ***!
  13575. \******************************/
  13576. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13578. "use strict";
  13579. __webpack_require__.r(__webpack_exports__);
  13580. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13582. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13584. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13586. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13588. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13590. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13592. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13594. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13596. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13598. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13600. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13602. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13604. /***/ }),
  13605. /***/ "./3D/controls/meshButton3D.ts":
  13606. /*!*************************************!*\
  13607. !*** ./3D/controls/meshButton3D.ts ***!
  13608. \*************************************/
  13609. /*! exports provided: MeshButton3D */
  13610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13611. "use strict";
  13612. __webpack_require__.r(__webpack_exports__);
  13613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13614. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13615. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13616. /**
  13617. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13618. */
  13619. var MeshButton3D = /** @class */ (function (_super) {
  13620. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13621. /**
  13622. * Creates a new 3D button based on a mesh
  13623. * @param mesh mesh to become a 3D button
  13624. * @param name defines the control name
  13625. */
  13626. function MeshButton3D(mesh, name) {
  13627. var _this = _super.call(this, name) || this;
  13628. _this._currentMesh = mesh;
  13629. /**
  13630. * Provides a default behavior on hover/out & up/down
  13631. * Override those function to create your own desired behavior specific to your mesh
  13632. */
  13633. _this.pointerEnterAnimation = function () {
  13634. if (!_this.mesh) {
  13635. return;
  13636. }
  13637. _this.mesh.scaling.scaleInPlace(1.1);
  13638. };
  13639. _this.pointerOutAnimation = function () {
  13640. if (!_this.mesh) {
  13641. return;
  13642. }
  13643. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13644. };
  13645. _this.pointerDownAnimation = function () {
  13646. if (!_this.mesh) {
  13647. return;
  13648. }
  13649. _this.mesh.scaling.scaleInPlace(0.95);
  13650. };
  13651. _this.pointerUpAnimation = function () {
  13652. if (!_this.mesh) {
  13653. return;
  13654. }
  13655. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13656. };
  13657. return _this;
  13658. }
  13659. MeshButton3D.prototype._getTypeName = function () {
  13660. return "MeshButton3D";
  13661. };
  13662. // Mesh association
  13663. MeshButton3D.prototype._createNode = function (scene) {
  13664. var _this = this;
  13665. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13666. mesh.metadata = _this;
  13667. });
  13668. return this._currentMesh;
  13669. };
  13670. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13671. };
  13672. return MeshButton3D;
  13673. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13674. /***/ }),
  13675. /***/ "./3D/controls/planePanel.ts":
  13676. /*!***********************************!*\
  13677. !*** ./3D/controls/planePanel.ts ***!
  13678. \***********************************/
  13679. /*! exports provided: PlanePanel */
  13680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13681. "use strict";
  13682. __webpack_require__.r(__webpack_exports__);
  13683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13684. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13685. <<<<<<< HEAD
  13686. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13687. =======
  13688. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  13689. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  13690. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13691. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13692. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13693. /**
  13694. * Class used to create a container panel deployed on the surface of a plane
  13695. */
  13696. var PlanePanel = /** @class */ (function (_super) {
  13697. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13698. function PlanePanel() {
  13699. return _super !== null && _super.apply(this, arguments) || this;
  13700. }
  13701. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13702. var mesh = control.mesh;
  13703. if (!mesh) {
  13704. return;
  13705. }
  13706. control.position = nodePosition.clone();
  13707. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13708. target.copyFrom(nodePosition);
  13709. switch (this.orientation) {
  13710. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13711. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13712. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13713. mesh.lookAt(target);
  13714. break;
  13715. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13716. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13717. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13718. mesh.lookAt(target);
  13719. break;
  13720. }
  13721. };
  13722. return PlanePanel;
  13723. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13724. /***/ }),
  13725. /***/ "./3D/controls/scatterPanel.ts":
  13726. /*!*************************************!*\
  13727. !*** ./3D/controls/scatterPanel.ts ***!
  13728. \*************************************/
  13729. /*! exports provided: ScatterPanel */
  13730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13731. "use strict";
  13732. __webpack_require__.r(__webpack_exports__);
  13733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13734. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13735. <<<<<<< HEAD
  13736. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13737. =======
  13738. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13739. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  13740. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13741. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13742. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13743. /**
  13744. * Class used to create a container panel where items get randomized planar mapping
  13745. */
  13746. var ScatterPanel = /** @class */ (function (_super) {
  13747. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13748. function ScatterPanel() {
  13749. var _this = _super !== null && _super.apply(this, arguments) || this;
  13750. _this._iteration = 100.0;
  13751. return _this;
  13752. }
  13753. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13754. /**
  13755. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13756. */
  13757. get: function () {
  13758. return this._iteration;
  13759. },
  13760. set: function (value) {
  13761. var _this = this;
  13762. if (this._iteration === value) {
  13763. return;
  13764. }
  13765. this._iteration = value;
  13766. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13767. _this._arrangeChildren();
  13768. });
  13769. },
  13770. enumerable: true,
  13771. configurable: true
  13772. });
  13773. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13774. var mesh = control.mesh;
  13775. var newPos = this._scatterMapping(nodePosition);
  13776. if (!mesh) {
  13777. return;
  13778. }
  13779. switch (this.orientation) {
  13780. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13781. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13782. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13783. break;
  13784. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13785. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13786. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13787. break;
  13788. }
  13789. control.position = newPos;
  13790. };
  13791. ScatterPanel.prototype._scatterMapping = function (source) {
  13792. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13793. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13794. return source;
  13795. };
  13796. ScatterPanel.prototype._finalProcessing = function () {
  13797. var meshes = [];
  13798. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13799. var child = _a[_i];
  13800. if (!child.mesh) {
  13801. continue;
  13802. }
  13803. meshes.push(child.mesh);
  13804. }
  13805. for (var count = 0; count < this._iteration; count++) {
  13806. meshes.sort(function (a, b) {
  13807. var distance1 = a.position.lengthSquared();
  13808. var distance2 = b.position.lengthSquared();
  13809. if (distance1 < distance2) {
  13810. return 1;
  13811. }
  13812. else if (distance1 > distance2) {
  13813. return -1;
  13814. }
  13815. return 0;
  13816. });
  13817. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13818. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13819. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector2[0];
  13820. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13821. for (var i = 0; i < meshes.length - 1; i++) {
  13822. for (var j = i + 1; j < meshes.length; j++) {
  13823. if (i != j) {
  13824. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13825. // Ignore Z axis
  13826. difference2D.x = difference.x;
  13827. difference2D.y = difference.y;
  13828. var combinedRadius = cellSize;
  13829. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13830. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13831. distance -= minSeparation;
  13832. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13833. difference2D.normalize();
  13834. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13835. meshes[j].position.addInPlace(difference);
  13836. meshes[i].position.subtractInPlace(difference);
  13837. }
  13838. }
  13839. }
  13840. }
  13841. }
  13842. };
  13843. return ScatterPanel;
  13844. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13845. /***/ }),
  13846. /***/ "./3D/controls/spherePanel.ts":
  13847. /*!************************************!*\
  13848. !*** ./3D/controls/spherePanel.ts ***!
  13849. \************************************/
  13850. /*! exports provided: SpherePanel */
  13851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13852. "use strict";
  13853. __webpack_require__.r(__webpack_exports__);
  13854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13855. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13856. <<<<<<< HEAD
  13857. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13858. =======
  13859. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13860. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  13861. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13862. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13863. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13864. /**
  13865. * Class used to create a container panel deployed on the surface of a sphere
  13866. */
  13867. var SpherePanel = /** @class */ (function (_super) {
  13868. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13869. function SpherePanel() {
  13870. var _this = _super !== null && _super.apply(this, arguments) || this;
  13871. _this._radius = 5.0;
  13872. return _this;
  13873. }
  13874. Object.defineProperty(SpherePanel.prototype, "radius", {
  13875. /**
  13876. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13877. */
  13878. get: function () {
  13879. return this._radius;
  13880. },
  13881. set: function (value) {
  13882. var _this = this;
  13883. if (this._radius === value) {
  13884. return;
  13885. }
  13886. this._radius = value;
  13887. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13888. _this._arrangeChildren();
  13889. });
  13890. },
  13891. enumerable: true,
  13892. configurable: true
  13893. });
  13894. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13895. var mesh = control.mesh;
  13896. if (!mesh) {
  13897. return;
  13898. }
  13899. var newPos = this._sphericalMapping(nodePosition);
  13900. control.position = newPos;
  13901. switch (this.orientation) {
  13902. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13903. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13904. break;
  13905. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13906. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13907. break;
  13908. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13909. break;
  13910. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13911. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13912. break;
  13913. }
  13914. };
  13915. SpherePanel.prototype._sphericalMapping = function (source) {
  13916. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13917. var xAngle = (source.y / this._radius);
  13918. var yAngle = -(source.x / this._radius);
  13919. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13920. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13921. };
  13922. return SpherePanel;
  13923. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13924. /***/ }),
  13925. /***/ "./3D/controls/stackPanel3D.ts":
  13926. /*!*************************************!*\
  13927. !*** ./3D/controls/stackPanel3D.ts ***!
  13928. \*************************************/
  13929. /*! exports provided: StackPanel3D */
  13930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13931. "use strict";
  13932. __webpack_require__.r(__webpack_exports__);
  13933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13934. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13935. <<<<<<< HEAD
  13936. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13937. =======
  13938. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  13939. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  13940. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13941. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13942. /**
  13943. * Class used to create a stack panel in 3D on XY plane
  13944. */
  13945. var StackPanel3D = /** @class */ (function (_super) {
  13946. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13947. /**
  13948. * Creates new StackPanel
  13949. * @param isVertical
  13950. */
  13951. function StackPanel3D(isVertical) {
  13952. if (isVertical === void 0) { isVertical = false; }
  13953. var _this = _super.call(this) || this;
  13954. _this._isVertical = false;
  13955. /**
  13956. * Gets or sets the distance between elements
  13957. */
  13958. _this.margin = 0.1;
  13959. _this._isVertical = isVertical;
  13960. return _this;
  13961. }
  13962. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13963. /**
  13964. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13965. */
  13966. get: function () {
  13967. return this._isVertical;
  13968. },
  13969. set: function (value) {
  13970. var _this = this;
  13971. if (this._isVertical === value) {
  13972. return;
  13973. }
  13974. this._isVertical = value;
  13975. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13976. _this._arrangeChildren();
  13977. });
  13978. },
  13979. enumerable: true,
  13980. configurable: true
  13981. });
  13982. StackPanel3D.prototype._arrangeChildren = function () {
  13983. var width = 0;
  13984. var height = 0;
  13985. var controlCount = 0;
  13986. var extendSizes = [];
  13987. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13988. // Measure
  13989. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13990. var child = _a[_i];
  13991. if (!child.mesh) {
  13992. continue;
  13993. }
  13994. controlCount++;
  13995. child.mesh.computeWorldMatrix(true);
  13996. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13997. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13998. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13999. extendSizes.push(extendSize);
  14000. if (this._isVertical) {
  14001. height += extendSize.y;
  14002. }
  14003. else {
  14004. width += extendSize.x;
  14005. }
  14006. }
  14007. if (this._isVertical) {
  14008. height += (controlCount - 1) * this.margin / 2;
  14009. }
  14010. else {
  14011. width += (controlCount - 1) * this.margin / 2;
  14012. }
  14013. // Arrange
  14014. var offset;
  14015. if (this._isVertical) {
  14016. offset = -height;
  14017. }
  14018. else {
  14019. offset = -width;
  14020. }
  14021. var index = 0;
  14022. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14023. var child = _c[_b];
  14024. if (!child.mesh) {
  14025. continue;
  14026. }
  14027. controlCount--;
  14028. var extendSize = extendSizes[index++];
  14029. if (this._isVertical) {
  14030. child.position.y = offset + extendSize.y;
  14031. child.position.x = 0;
  14032. offset += extendSize.y * 2;
  14033. }
  14034. else {
  14035. child.position.x = offset + extendSize.x;
  14036. child.position.y = 0;
  14037. offset += extendSize.x * 2;
  14038. }
  14039. offset += (controlCount > 0 ? this.margin : 0);
  14040. }
  14041. };
  14042. return StackPanel3D;
  14043. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14044. /***/ }),
  14045. /***/ "./3D/controls/volumeBasedPanel.ts":
  14046. /*!*****************************************!*\
  14047. !*** ./3D/controls/volumeBasedPanel.ts ***!
  14048. \*****************************************/
  14049. /*! exports provided: VolumeBasedPanel */
  14050. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14051. "use strict";
  14052. __webpack_require__.r(__webpack_exports__);
  14053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  14054. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14055. <<<<<<< HEAD
  14056. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  14057. =======
  14058. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  14059. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  14060. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14061. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14062. /**
  14063. * Abstract class used to create a container panel deployed on the surface of a volume
  14064. */
  14065. var VolumeBasedPanel = /** @class */ (function (_super) {
  14066. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  14067. /**
  14068. * Creates new VolumeBasedPanel
  14069. */
  14070. function VolumeBasedPanel() {
  14071. var _this = _super.call(this) || this;
  14072. _this._columns = 10;
  14073. _this._rows = 0;
  14074. _this._rowThenColum = true;
  14075. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  14076. /**
  14077. * Gets or sets the distance between elements
  14078. */
  14079. _this.margin = 0;
  14080. return _this;
  14081. }
  14082. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  14083. /**
  14084. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  14085. * | Value | Type | Description |
  14086. * | ----- | ----------------------------------- | ----------- |
  14087. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  14088. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  14089. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  14090. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  14091. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  14092. */
  14093. get: function () {
  14094. return this._orientation;
  14095. },
  14096. set: function (value) {
  14097. var _this = this;
  14098. if (this._orientation === value) {
  14099. return;
  14100. }
  14101. this._orientation = value;
  14102. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14103. _this._arrangeChildren();
  14104. });
  14105. },
  14106. enumerable: true,
  14107. configurable: true
  14108. });
  14109. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  14110. /**
  14111. * Gets or sets the number of columns requested (10 by default).
  14112. * The panel will automatically compute the number of rows based on number of child controls.
  14113. */
  14114. get: function () {
  14115. return this._columns;
  14116. },
  14117. set: function (value) {
  14118. var _this = this;
  14119. if (this._columns === value) {
  14120. return;
  14121. }
  14122. this._columns = value;
  14123. this._rowThenColum = true;
  14124. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14125. _this._arrangeChildren();
  14126. });
  14127. },
  14128. enumerable: true,
  14129. configurable: true
  14130. });
  14131. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14132. /**
  14133. * Gets or sets a the number of rows requested.
  14134. * The panel will automatically compute the number of columns based on number of child controls.
  14135. */
  14136. get: function () {
  14137. return this._rows;
  14138. },
  14139. set: function (value) {
  14140. var _this = this;
  14141. if (this._rows === value) {
  14142. return;
  14143. }
  14144. this._rows = value;
  14145. this._rowThenColum = false;
  14146. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14147. _this._arrangeChildren();
  14148. });
  14149. },
  14150. enumerable: true,
  14151. configurable: true
  14152. });
  14153. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14154. this._cellWidth = 0;
  14155. this._cellHeight = 0;
  14156. var rows = 0;
  14157. var columns = 0;
  14158. var controlCount = 0;
  14159. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14160. // Measure
  14161. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14162. var child = _a[_i];
  14163. if (!child.mesh) {
  14164. continue;
  14165. }
  14166. controlCount++;
  14167. child.mesh.computeWorldMatrix(true);
  14168. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14169. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14170. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  14171. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  14172. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14173. diff.scaleInPlace(0.5);
  14174. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14175. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14176. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14177. }
  14178. this._cellWidth += this.margin * 2;
  14179. this._cellHeight += this.margin * 2;
  14180. // Arrange
  14181. if (this._rowThenColum) {
  14182. columns = this._columns;
  14183. rows = Math.ceil(controlCount / this._columns);
  14184. }
  14185. else {
  14186. rows = this._rows;
  14187. columns = Math.ceil(controlCount / this._rows);
  14188. }
  14189. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14190. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14191. var nodeGrid = [];
  14192. var cellCounter = 0;
  14193. if (this._rowThenColum) {
  14194. for (var r = 0; r < rows; r++) {
  14195. for (var c = 0; c < columns; c++) {
  14196. 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));
  14197. cellCounter++;
  14198. if (cellCounter > controlCount) {
  14199. break;
  14200. }
  14201. }
  14202. }
  14203. }
  14204. else {
  14205. for (var c = 0; c < columns; c++) {
  14206. for (var r = 0; r < rows; r++) {
  14207. 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));
  14208. cellCounter++;
  14209. if (cellCounter > controlCount) {
  14210. break;
  14211. }
  14212. }
  14213. }
  14214. }
  14215. cellCounter = 0;
  14216. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14217. var child = _c[_b];
  14218. if (!child.mesh) {
  14219. continue;
  14220. }
  14221. this._mapGridNode(child, nodeGrid[cellCounter]);
  14222. cellCounter++;
  14223. }
  14224. this._finalProcessing();
  14225. };
  14226. /** Child classes can implement this function to provide additional processing */
  14227. VolumeBasedPanel.prototype._finalProcessing = function () {
  14228. };
  14229. return VolumeBasedPanel;
  14230. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14231. /***/ }),
  14232. /***/ "./3D/gui3DManager.ts":
  14233. /*!****************************!*\
  14234. !*** ./3D/gui3DManager.ts ***!
  14235. \****************************/
  14236. /*! exports provided: GUI3DManager */
  14237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14238. "use strict";
  14239. __webpack_require__.r(__webpack_exports__);
  14240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14241. <<<<<<< HEAD
  14242. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  14243. =======
  14244. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  14245. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  14246. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14247. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14248. /**
  14249. * Class used to manage 3D user interface
  14250. * @see http://doc.babylonjs.com/how_to/gui3d
  14251. */
  14252. var GUI3DManager = /** @class */ (function () {
  14253. /**
  14254. * Creates a new GUI3DManager
  14255. * @param scene
  14256. */
  14257. function GUI3DManager(scene) {
  14258. var _this = this;
  14259. /** @hidden */
  14260. this._lastControlOver = {};
  14261. /** @hidden */
  14262. this._lastControlDown = {};
  14263. /**
  14264. * Observable raised when the point picked by the pointer events changed
  14265. */
  14266. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14267. // Shared resources
  14268. /** @hidden */
  14269. this._sharedMaterials = {};
  14270. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14271. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14272. _this._sceneDisposeObserver = null;
  14273. _this._utilityLayer = null;
  14274. _this.dispose();
  14275. });
  14276. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14277. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14278. this._utilityLayer.pickUtilitySceneFirst = false;
  14279. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14280. return mesh && mesh.metadata && mesh.metadata._node;
  14281. };
  14282. // Root
  14283. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14284. this._rootContainer._host = this;
  14285. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14286. // Events
  14287. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14288. _this._handlePointerOut(pointerId, true);
  14289. });
  14290. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14291. _this._doPicking(pi);
  14292. });
  14293. // Scene
  14294. this._utilityLayer.utilityLayerScene.autoClear = false;
  14295. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14296. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14297. }
  14298. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14299. /** Gets the hosting scene */
  14300. get: function () {
  14301. return this._scene;
  14302. },
  14303. enumerable: true,
  14304. configurable: true
  14305. });
  14306. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14307. /** Gets associated utility layer */
  14308. get: function () {
  14309. return this._utilityLayer;
  14310. },
  14311. enumerable: true,
  14312. configurable: true
  14313. });
  14314. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14315. var previousControlOver = this._lastControlOver[pointerId];
  14316. if (previousControlOver) {
  14317. previousControlOver._onPointerOut(previousControlOver);
  14318. delete this._lastControlOver[pointerId];
  14319. }
  14320. if (isPointerUp) {
  14321. if (this._lastControlDown[pointerId]) {
  14322. this._lastControlDown[pointerId].forcePointerUp();
  14323. delete this._lastControlDown[pointerId];
  14324. }
  14325. }
  14326. this.onPickedPointChangedObservable.notifyObservers(null);
  14327. };
  14328. GUI3DManager.prototype._doPicking = function (pi) {
  14329. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14330. return false;
  14331. }
  14332. var pointerEvent = (pi.event);
  14333. var pointerId = pointerEvent.pointerId || 0;
  14334. var buttonIndex = pointerEvent.button;
  14335. var pickingInfo = pi.pickInfo;
  14336. if (!pickingInfo || !pickingInfo.hit) {
  14337. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14338. return false;
  14339. }
  14340. var control = (pickingInfo.pickedMesh.metadata);
  14341. if (pickingInfo.pickedPoint) {
  14342. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14343. }
  14344. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14345. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14346. if (this._lastControlOver[pointerId]) {
  14347. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14348. }
  14349. delete this._lastControlOver[pointerId];
  14350. }
  14351. }
  14352. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14353. if (this._lastControlDown[pointerEvent.pointerId]) {
  14354. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14355. delete this._lastControlDown[pointerEvent.pointerId];
  14356. }
  14357. if (pointerEvent.pointerType === "touch") {
  14358. this._handlePointerOut(pointerId, false);
  14359. }
  14360. }
  14361. return true;
  14362. };
  14363. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14364. /**
  14365. * Gets the root container
  14366. */
  14367. get: function () {
  14368. return this._rootContainer;
  14369. },
  14370. enumerable: true,
  14371. configurable: true
  14372. });
  14373. /**
  14374. * Gets a boolean indicating if the given control is in the root child list
  14375. * @param control defines the control to check
  14376. * @returns true if the control is in the root child list
  14377. */
  14378. GUI3DManager.prototype.containsControl = function (control) {
  14379. return this._rootContainer.containsControl(control);
  14380. };
  14381. /**
  14382. * Adds a control to the root child list
  14383. * @param control defines the control to add
  14384. * @returns the current manager
  14385. */
  14386. GUI3DManager.prototype.addControl = function (control) {
  14387. this._rootContainer.addControl(control);
  14388. return this;
  14389. };
  14390. /**
  14391. * Removes a control from the root child list
  14392. * @param control defines the control to remove
  14393. * @returns the current container
  14394. */
  14395. GUI3DManager.prototype.removeControl = function (control) {
  14396. this._rootContainer.removeControl(control);
  14397. return this;
  14398. };
  14399. /**
  14400. * Releases all associated resources
  14401. */
  14402. GUI3DManager.prototype.dispose = function () {
  14403. this._rootContainer.dispose();
  14404. for (var materialName in this._sharedMaterials) {
  14405. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14406. continue;
  14407. }
  14408. this._sharedMaterials[materialName].dispose();
  14409. }
  14410. this._sharedMaterials = {};
  14411. if (this._pointerOutObserver && this._utilityLayer) {
  14412. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14413. this._pointerOutObserver = null;
  14414. }
  14415. this.onPickedPointChangedObservable.clear();
  14416. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14417. if (utilityLayerScene) {
  14418. if (this._pointerObserver) {
  14419. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14420. this._pointerObserver = null;
  14421. }
  14422. }
  14423. if (this._scene) {
  14424. if (this._sceneDisposeObserver) {
  14425. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14426. this._sceneDisposeObserver = null;
  14427. }
  14428. }
  14429. if (this._utilityLayer) {
  14430. this._utilityLayer.dispose();
  14431. }
  14432. };
  14433. return GUI3DManager;
  14434. }());
  14435. /***/ }),
  14436. /***/ "./3D/index.ts":
  14437. /*!*********************!*\
  14438. !*** ./3D/index.ts ***!
  14439. \*********************/
  14440. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14441. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14442. "use strict";
  14443. __webpack_require__.r(__webpack_exports__);
  14444. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14457. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14460. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14462. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14464. /***/ }),
  14465. /***/ "./3D/materials/fluentMaterial.ts":
  14466. /*!****************************************!*\
  14467. !*** ./3D/materials/fluentMaterial.ts ***!
  14468. \****************************************/
  14469. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14471. "use strict";
  14472. __webpack_require__.r(__webpack_exports__);
  14473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14475. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14476. <<<<<<< HEAD
  14477. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  14478. =======
  14479. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/tools");
  14480. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  14481. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14482. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14483. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14484. /** @hidden */
  14485. var FluentMaterialDefines = /** @class */ (function (_super) {
  14486. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14487. function FluentMaterialDefines() {
  14488. var _this = _super.call(this) || this;
  14489. _this.INNERGLOW = false;
  14490. _this.BORDER = false;
  14491. _this.HOVERLIGHT = false;
  14492. _this.TEXTURE = false;
  14493. _this.rebuild();
  14494. return _this;
  14495. }
  14496. return FluentMaterialDefines;
  14497. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14498. /**
  14499. * Class used to render controls with fluent desgin
  14500. */
  14501. var FluentMaterial = /** @class */ (function (_super) {
  14502. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14503. /**
  14504. * Creates a new Fluent material
  14505. * @param name defines the name of the material
  14506. * @param scene defines the hosting scene
  14507. */
  14508. function FluentMaterial(name, scene) {
  14509. var _this = _super.call(this, name, scene) || this;
  14510. /**
  14511. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14512. */
  14513. _this.innerGlowColorIntensity = 0.5;
  14514. /**
  14515. * Gets or sets the inner glow color (white by default)
  14516. */
  14517. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14518. /**
  14519. * Gets or sets alpha value (default is 1.0)
  14520. */
  14521. _this.alpha = 1.0;
  14522. /**
  14523. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14524. */
  14525. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14526. /**
  14527. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14528. */
  14529. _this.renderBorders = false;
  14530. /**
  14531. * Gets or sets border width (default is 0.5)
  14532. */
  14533. _this.borderWidth = 0.5;
  14534. /**
  14535. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14536. */
  14537. _this.edgeSmoothingValue = 0.02;
  14538. /**
  14539. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14540. */
  14541. _this.borderMinValue = 0.1;
  14542. /**
  14543. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14544. */
  14545. _this.renderHoverLight = false;
  14546. /**
  14547. * Gets or sets the radius used to render the hover light (default is 1.0)
  14548. */
  14549. _this.hoverRadius = 1.0;
  14550. /**
  14551. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14552. */
  14553. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14554. /**
  14555. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14556. */
  14557. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14558. return _this;
  14559. }
  14560. FluentMaterial.prototype.needAlphaBlending = function () {
  14561. return this.alpha !== 1.0;
  14562. };
  14563. FluentMaterial.prototype.needAlphaTesting = function () {
  14564. return false;
  14565. };
  14566. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14567. return null;
  14568. };
  14569. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14570. if (this.isFrozen) {
  14571. if (this._wasPreviouslyReady && subMesh.effect) {
  14572. return true;
  14573. }
  14574. }
  14575. if (!subMesh._materialDefines) {
  14576. subMesh._materialDefines = new FluentMaterialDefines();
  14577. }
  14578. var scene = this.getScene();
  14579. var defines = subMesh._materialDefines;
  14580. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14581. if (defines._renderId === scene.getRenderId()) {
  14582. return true;
  14583. }
  14584. }
  14585. if (defines._areTexturesDirty) {
  14586. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14587. defines.BORDER = this.renderBorders;
  14588. defines.HOVERLIGHT = this.renderHoverLight;
  14589. if (this._albedoTexture) {
  14590. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14591. return false;
  14592. }
  14593. else {
  14594. defines.TEXTURE = true;
  14595. }
  14596. }
  14597. else {
  14598. defines.TEXTURE = false;
  14599. }
  14600. }
  14601. var engine = scene.getEngine();
  14602. // Get correct effect
  14603. if (defines.isDirty) {
  14604. defines.markAsProcessed();
  14605. scene.resetCachedMaterial();
  14606. //Attributes
  14607. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14608. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14609. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14610. var shaderName = "fluent";
  14611. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14612. "hoverColor", "hoverPosition", "hoverRadius"
  14613. ];
  14614. var samplers = ["albedoSampler"];
  14615. var uniformBuffers = new Array();
  14616. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14617. uniformsNames: uniforms,
  14618. uniformBuffersNames: uniformBuffers,
  14619. samplers: samplers,
  14620. defines: defines,
  14621. maxSimultaneousLights: 4
  14622. });
  14623. var join = defines.toString();
  14624. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14625. attributes: attribs,
  14626. uniformsNames: uniforms,
  14627. uniformBuffersNames: uniformBuffers,
  14628. samplers: samplers,
  14629. defines: join,
  14630. fallbacks: null,
  14631. onCompiled: this.onCompiled,
  14632. onError: this.onError,
  14633. indexParameters: { maxSimultaneousLights: 4 }
  14634. }, engine));
  14635. }
  14636. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14637. return false;
  14638. }
  14639. defines._renderId = scene.getRenderId();
  14640. this._wasPreviouslyReady = true;
  14641. return true;
  14642. };
  14643. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14644. var scene = this.getScene();
  14645. var defines = subMesh._materialDefines;
  14646. if (!defines) {
  14647. return;
  14648. }
  14649. var effect = subMesh.effect;
  14650. if (!effect) {
  14651. return;
  14652. }
  14653. this._activeEffect = effect;
  14654. // Matrices
  14655. this.bindOnlyWorldMatrix(world);
  14656. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14657. if (this._mustRebind(scene, effect)) {
  14658. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14659. if (defines.INNERGLOW) {
  14660. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14661. }
  14662. if (defines.BORDER) {
  14663. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14664. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14665. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14666. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14667. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14668. }
  14669. if (defines.HOVERLIGHT) {
  14670. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14671. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14672. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14673. }
  14674. if (defines.TEXTURE) {
  14675. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14676. }
  14677. }
  14678. this._afterBind(mesh, this._activeEffect);
  14679. };
  14680. FluentMaterial.prototype.getActiveTextures = function () {
  14681. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14682. return activeTextures;
  14683. };
  14684. FluentMaterial.prototype.hasTexture = function (texture) {
  14685. if (_super.prototype.hasTexture.call(this, texture)) {
  14686. return true;
  14687. }
  14688. return false;
  14689. };
  14690. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14691. _super.prototype.dispose.call(this, forceDisposeEffect);
  14692. };
  14693. FluentMaterial.prototype.clone = function (name) {
  14694. var _this = this;
  14695. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14696. };
  14697. FluentMaterial.prototype.serialize = function () {
  14698. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14699. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14700. return serializationObject;
  14701. };
  14702. FluentMaterial.prototype.getClassName = function () {
  14703. return "FluentMaterial";
  14704. };
  14705. // Statics
  14706. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14707. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14708. };
  14709. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14710. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14711. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14712. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14713. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14714. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14715. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14716. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14717. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14718. ], FluentMaterial.prototype, "alpha", void 0);
  14719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14720. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14721. ], FluentMaterial.prototype, "albedoColor", void 0);
  14722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14723. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14724. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14725. ], FluentMaterial.prototype, "renderBorders", void 0);
  14726. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14727. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14728. ], FluentMaterial.prototype, "borderWidth", void 0);
  14729. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14730. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14731. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14732. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14733. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14734. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14735. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14736. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14737. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14738. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14739. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14740. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14741. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14742. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14743. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14744. ], FluentMaterial.prototype, "hoverColor", void 0);
  14745. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14746. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14747. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14748. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14749. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14750. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14751. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14752. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14753. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14754. return FluentMaterial;
  14755. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14756. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14757. /***/ }),
  14758. /***/ "./3D/materials/index.ts":
  14759. /*!*******************************!*\
  14760. !*** ./3D/materials/index.ts ***!
  14761. \*******************************/
  14762. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14763. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14764. "use strict";
  14765. __webpack_require__.r(__webpack_exports__);
  14766. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14769. /***/ }),
  14770. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14771. /*!*************************************************!*\
  14772. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14773. \*************************************************/
  14774. /*! exports provided: fluentPixelShader */
  14775. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14776. "use strict";
  14777. __webpack_require__.r(__webpack_exports__);
  14778. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14779. <<<<<<< HEAD
  14780. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14781. =======
  14782. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/tools");
  14783. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  14784. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14785. var name = 'fluentPixelShader';
  14786. 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}";
  14787. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14788. /** @hidden */
  14789. var fluentPixelShader = { name: name, shader: shader };
  14790. /***/ }),
  14791. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14792. /*!***********************************************!*\
  14793. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14794. \***********************************************/
  14795. /*! exports provided: fluentVertexShader */
  14796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14797. "use strict";
  14798. __webpack_require__.r(__webpack_exports__);
  14799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14800. <<<<<<< HEAD
  14801. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14802. =======
  14803. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/tools");
  14804. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  14805. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14806. var name = 'fluentVertexShader';
  14807. 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";
  14808. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14809. /** @hidden */
  14810. var fluentVertexShader = { name: name, shader: shader };
  14811. /***/ }),
  14812. /***/ "./3D/vector3WithInfo.ts":
  14813. /*!*******************************!*\
  14814. !*** ./3D/vector3WithInfo.ts ***!
  14815. \*******************************/
  14816. /*! exports provided: Vector3WithInfo */
  14817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14818. "use strict";
  14819. __webpack_require__.r(__webpack_exports__);
  14820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14821. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14822. <<<<<<< HEAD
  14823. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  14824. =======
  14825. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/tools");
  14826. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  14827. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14828. /**
  14829. * Class used to transport Vector3 information for pointer events
  14830. */
  14831. var Vector3WithInfo = /** @class */ (function (_super) {
  14832. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14833. /**
  14834. * Creates a new Vector3WithInfo
  14835. * @param source defines the vector3 data to transport
  14836. * @param buttonIndex defines the current mouse button index
  14837. */
  14838. function Vector3WithInfo(source,
  14839. /** defines the current mouse button index */
  14840. buttonIndex) {
  14841. if (buttonIndex === void 0) { buttonIndex = 0; }
  14842. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14843. _this.buttonIndex = buttonIndex;
  14844. return _this;
  14845. }
  14846. return Vector3WithInfo;
  14847. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14848. /***/ }),
  14849. /***/ "./index.ts":
  14850. /*!******************!*\
  14851. !*** ./index.ts ***!
  14852. \******************/
  14853. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14854. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14855. "use strict";
  14856. __webpack_require__.r(__webpack_exports__);
  14857. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14897. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14914. /***/ }),
  14915. /***/ "./legacy/legacy.ts":
  14916. /*!**************************!*\
  14917. !*** ./legacy/legacy.ts ***!
  14918. \**************************/
  14919. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14920. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14921. "use strict";
  14922. __webpack_require__.r(__webpack_exports__);
  14923. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14979. /**
  14980. * Legacy support, defining window.BABYLON.GUI (global variable).
  14981. *
  14982. * This is the entry point for the UMD module.
  14983. * The entry point for a future ESM package should be index.ts
  14984. */
  14985. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14986. if (typeof globalObject !== "undefined") {
  14987. globalObject.BABYLON = globalObject.BABYLON || {};
  14988. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14989. }
  14990. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14991. /***/ }),
  14992. <<<<<<< HEAD
  14993. /***/ "babylonjs/Misc/observable":
  14994. =======
  14995. /***/ "babylonjs/Misc/tools":
  14996. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  14997. /*!****************************************************************************************************!*\
  14998. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14999. \****************************************************************************************************/
  15000. /*! no static exports found */
  15001. /***/ (function(module, exports) {
  15002. <<<<<<< HEAD
  15003. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;
  15004. =======
  15005. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_tools__;
  15006. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  15007. /***/ })
  15008. /******/ });
  15009. });
  15010. //# sourceMappingURL=babylon.gui.js.map