babylon.gui.js 672 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** D:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../../node_modules/webpack/buildin/global.js":
  291. /*!***********************************!*\
  292. !*** (webpack)/buildin/global.js ***!
  293. \***********************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./2D/adtInstrumentation.ts":
  314. /*!**********************************!*\
  315. !*** ./2D/adtInstrumentation.ts ***!
  316. \**********************************/
  317. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  322. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  323. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
  324. /**
  325. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  326. */
  327. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  328. /**
  329. * Instantiates a new advanced dynamic texture instrumentation.
  330. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  331. * @param texture Defines the AdvancedDynamicTexture to instrument
  332. */
  333. function AdvancedDynamicTextureInstrumentation(
  334. /**
  335. * Define the instrumented AdvancedDynamicTexture.
  336. */
  337. texture) {
  338. this.texture = texture;
  339. this._captureRenderTime = false;
  340. this._renderTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  341. this._captureLayoutTime = false;
  342. this._layoutTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  343. // Observers
  344. this._onBeginRenderObserver = null;
  345. this._onEndRenderObserver = null;
  346. this._onBeginLayoutObserver = null;
  347. this._onEndLayoutObserver = null;
  348. }
  349. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  350. // Properties
  351. /**
  352. * Gets the perf counter used to capture render time
  353. */
  354. get: function () {
  355. return this._renderTime;
  356. },
  357. enumerable: true,
  358. configurable: true
  359. });
  360. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  361. /**
  362. * Gets the perf counter used to capture layout time
  363. */
  364. get: function () {
  365. return this._layoutTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  371. /**
  372. * Enable or disable the render time capture
  373. */
  374. get: function () {
  375. return this._captureRenderTime;
  376. },
  377. set: function (value) {
  378. var _this = this;
  379. if (value === this._captureRenderTime) {
  380. return;
  381. }
  382. this._captureRenderTime = value;
  383. if (value) {
  384. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  385. _this._renderTime.beginMonitoring();
  386. });
  387. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  388. _this._renderTime.endMonitoring(true);
  389. });
  390. }
  391. else {
  392. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  393. this._onBeginRenderObserver = null;
  394. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  395. this._onEndRenderObserver = null;
  396. }
  397. },
  398. enumerable: true,
  399. configurable: true
  400. });
  401. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  402. /**
  403. * Enable or disable the layout time capture
  404. */
  405. get: function () {
  406. return this._captureLayoutTime;
  407. },
  408. set: function (value) {
  409. var _this = this;
  410. if (value === this._captureLayoutTime) {
  411. return;
  412. }
  413. this._captureLayoutTime = value;
  414. if (value) {
  415. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  416. _this._layoutTime.beginMonitoring();
  417. });
  418. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  419. _this._layoutTime.endMonitoring(true);
  420. });
  421. }
  422. else {
  423. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  424. this._onBeginLayoutObserver = null;
  425. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  426. this._onEndLayoutObserver = null;
  427. }
  428. },
  429. enumerable: true,
  430. configurable: true
  431. });
  432. /**
  433. * Dispose and release associated resources.
  434. */
  435. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  436. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  437. this._onBeginRenderObserver = null;
  438. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  439. this._onEndRenderObserver = null;
  440. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  441. this._onBeginLayoutObserver = null;
  442. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  443. this._onEndLayoutObserver = null;
  444. this.texture = null;
  445. };
  446. return AdvancedDynamicTextureInstrumentation;
  447. }());
  448. /***/ }),
  449. /***/ "./2D/advancedDynamicTexture.ts":
  450. /*!**************************************!*\
  451. !*** ./2D/advancedDynamicTexture.ts ***!
  452. \**************************************/
  453. /*! exports provided: AdvancedDynamicTexture */
  454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  455. "use strict";
  456. __webpack_require__.r(__webpack_exports__);
  457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  459. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  460. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  461. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  462. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  463. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  464. /**
  465. * Class used to create texture to support 2D GUI elements
  466. * @see http://doc.babylonjs.com/how_to/gui
  467. */
  468. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  469. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AdvancedDynamicTexture, _super);
  470. /**
  471. * Creates a new AdvancedDynamicTexture
  472. * @param name defines the name of the texture
  473. * @param width defines the width of the texture
  474. * @param height defines the height of the texture
  475. * @param scene defines the hosting scene
  476. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  477. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  478. */
  479. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  480. if (width === void 0) { width = 0; }
  481. if (height === void 0) { height = 0; }
  482. if (generateMipMaps === void 0) { generateMipMaps = false; }
  483. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  484. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA) || this;
  485. _this._isDirty = false;
  486. /** @hidden */
  487. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  488. /** @hidden */
  489. _this._lastControlOver = {};
  490. /** @hidden */
  491. _this._lastControlDown = {};
  492. /** @hidden */
  493. _this._capturingControl = {};
  494. /** @hidden */
  495. _this._linkedControls = new Array();
  496. _this._isFullscreen = false;
  497. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  498. _this._idealWidth = 0;
  499. _this._idealHeight = 0;
  500. _this._useSmallestIdeal = false;
  501. _this._renderAtIdealSize = false;
  502. _this._blockNextFocusCheck = false;
  503. _this._renderScale = 1;
  504. /**
  505. * Define type to string to ensure compatibility across browsers
  506. * Safari doesn't support DataTransfer constructor
  507. */
  508. _this._clipboardData = "";
  509. /**
  510. * Observable event triggered each time an clipboard event is received from the rendering canvas
  511. */
  512. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  513. /**
  514. * Observable event triggered each time a pointer down is intercepted by a control
  515. */
  516. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  517. /**
  518. * Observable event triggered before layout is evaluated
  519. */
  520. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  521. /**
  522. * Observable event triggered after the layout was evaluated
  523. */
  524. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  525. /**
  526. * Observable event triggered before the texture is rendered
  527. */
  528. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  529. /**
  530. * Observable event triggered after the texture was rendered
  531. */
  532. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  533. /**
  534. * Gets or sets a boolean defining if alpha is stored as premultiplied
  535. */
  536. _this.premulAlpha = false;
  537. _this._useInvalidateRectOptimization = true;
  538. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  539. _this._invalidatedRectangle = null;
  540. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  541. /** @hidden */
  542. _this.onClipboardCopy = function (rawEvt) {
  543. var evt = rawEvt;
  544. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  545. _this.onClipboardObservable.notifyObservers(ev);
  546. evt.preventDefault();
  547. };
  548. /** @hidden */
  549. _this.onClipboardCut = function (rawEvt) {
  550. var evt = rawEvt;
  551. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  552. _this.onClipboardObservable.notifyObservers(ev);
  553. evt.preventDefault();
  554. };
  555. /** @hidden */
  556. _this.onClipboardPaste = function (rawEvt) {
  557. var evt = rawEvt;
  558. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  559. _this.onClipboardObservable.notifyObservers(ev);
  560. evt.preventDefault();
  561. };
  562. scene = _this.getScene();
  563. if (!scene || !_this._texture) {
  564. return _this;
  565. }
  566. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  567. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  568. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  569. if (!_this._focusedControl) {
  570. return;
  571. }
  572. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  573. _this._focusedControl.processKeyboard(info.event);
  574. }
  575. info.skipOnPointerObservable = true;
  576. });
  577. _this._rootContainer._link(_this);
  578. _this.hasAlpha = true;
  579. if (!width || !height) {
  580. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  581. _this._onResize();
  582. }
  583. _this._texture.isReady = true;
  584. return _this;
  585. }
  586. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  587. /**
  588. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  589. * Useful when you want more antialiasing
  590. */
  591. get: function () {
  592. return this._renderScale;
  593. },
  594. set: function (value) {
  595. if (value === this._renderScale) {
  596. return;
  597. }
  598. this._renderScale = value;
  599. this._onResize();
  600. },
  601. enumerable: true,
  602. configurable: true
  603. });
  604. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  605. /** Gets or sets the background color */
  606. get: function () {
  607. return this._background;
  608. },
  609. set: function (value) {
  610. if (this._background === value) {
  611. return;
  612. }
  613. this._background = value;
  614. this.markAsDirty();
  615. },
  616. enumerable: true,
  617. configurable: true
  618. });
  619. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  620. /**
  621. * Gets or sets the ideal width used to design controls.
  622. * The GUI will then rescale everything accordingly
  623. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  624. */
  625. get: function () {
  626. return this._idealWidth;
  627. },
  628. set: function (value) {
  629. if (this._idealWidth === value) {
  630. return;
  631. }
  632. this._idealWidth = value;
  633. this.markAsDirty();
  634. this._rootContainer._markAllAsDirty();
  635. },
  636. enumerable: true,
  637. configurable: true
  638. });
  639. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  640. /**
  641. * Gets or sets the ideal height used to design controls.
  642. * The GUI will then rescale everything accordingly
  643. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  644. */
  645. get: function () {
  646. return this._idealHeight;
  647. },
  648. set: function (value) {
  649. if (this._idealHeight === value) {
  650. return;
  651. }
  652. this._idealHeight = value;
  653. this.markAsDirty();
  654. this._rootContainer._markAllAsDirty();
  655. },
  656. enumerable: true,
  657. configurable: true
  658. });
  659. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  660. /**
  661. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  662. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  663. */
  664. get: function () {
  665. return this._useSmallestIdeal;
  666. },
  667. set: function (value) {
  668. if (this._useSmallestIdeal === value) {
  669. return;
  670. }
  671. this._useSmallestIdeal = value;
  672. this.markAsDirty();
  673. this._rootContainer._markAllAsDirty();
  674. },
  675. enumerable: true,
  676. configurable: true
  677. });
  678. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  679. /**
  680. * Gets or sets a boolean indicating if adaptive scaling must be used
  681. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  682. */
  683. get: function () {
  684. return this._renderAtIdealSize;
  685. },
  686. set: function (value) {
  687. if (this._renderAtIdealSize === value) {
  688. return;
  689. }
  690. this._renderAtIdealSize = value;
  691. this._onResize();
  692. },
  693. enumerable: true,
  694. configurable: true
  695. });
  696. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  697. /**
  698. * Gets the underlying layer used to render the texture when in fullscreen mode
  699. */
  700. get: function () {
  701. return this._layerToDispose;
  702. },
  703. enumerable: true,
  704. configurable: true
  705. });
  706. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  707. /**
  708. * Gets the root container control
  709. */
  710. get: function () {
  711. return this._rootContainer;
  712. },
  713. enumerable: true,
  714. configurable: true
  715. });
  716. /**
  717. * Returns an array containing the root container.
  718. * This is mostly used to let the Inspector introspects the ADT
  719. * @returns an array containing the rootContainer
  720. */
  721. AdvancedDynamicTexture.prototype.getChildren = function () {
  722. return [this._rootContainer];
  723. };
  724. /**
  725. * Will return all controls that are inside this texture
  726. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  727. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  728. * @return all child controls
  729. */
  730. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  731. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  732. };
  733. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  734. /**
  735. * Gets or sets the current focused control
  736. */
  737. get: function () {
  738. return this._focusedControl;
  739. },
  740. set: function (control) {
  741. if (this._focusedControl == control) {
  742. return;
  743. }
  744. if (this._focusedControl) {
  745. this._focusedControl.onBlur();
  746. }
  747. if (control) {
  748. control.onFocus();
  749. }
  750. this._focusedControl = control;
  751. },
  752. enumerable: true,
  753. configurable: true
  754. });
  755. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  756. /**
  757. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  758. */
  759. get: function () {
  760. if (!this.layer) {
  761. return true;
  762. }
  763. return (!this.layer.isBackground);
  764. },
  765. set: function (value) {
  766. if (!this.layer) {
  767. return;
  768. }
  769. if (this.layer.isBackground === !value) {
  770. return;
  771. }
  772. this.layer.isBackground = !value;
  773. },
  774. enumerable: true,
  775. configurable: true
  776. });
  777. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  778. /**
  779. * Gets or set information about clipboardData
  780. */
  781. get: function () {
  782. return this._clipboardData;
  783. },
  784. set: function (value) {
  785. this._clipboardData = value;
  786. },
  787. enumerable: true,
  788. configurable: true
  789. });
  790. /**
  791. * Get the current class name of the texture useful for serialization or dynamic coding.
  792. * @returns "AdvancedDynamicTexture"
  793. */
  794. AdvancedDynamicTexture.prototype.getClassName = function () {
  795. return "AdvancedDynamicTexture";
  796. };
  797. /**
  798. * Function used to execute a function on all controls
  799. * @param func defines the function to execute
  800. * @param container defines the container where controls belong. If null the root container will be used
  801. */
  802. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  803. if (!container) {
  804. container = this._rootContainer;
  805. }
  806. func(container);
  807. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  808. var child = _a[_i];
  809. if (child.children) {
  810. this.executeOnAllControls(func, child);
  811. continue;
  812. }
  813. func(child);
  814. }
  815. };
  816. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  817. /**
  818. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  819. */
  820. get: function () {
  821. return this._useInvalidateRectOptimization;
  822. },
  823. set: function (value) {
  824. this._useInvalidateRectOptimization = value;
  825. },
  826. enumerable: true,
  827. configurable: true
  828. });
  829. /**
  830. * Invalidates a rectangle area on the gui texture
  831. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  832. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  833. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  834. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  835. */
  836. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  837. if (!this._useInvalidateRectOptimization) {
  838. return;
  839. }
  840. if (!this._invalidatedRectangle) {
  841. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  842. }
  843. else {
  844. // Compute intersection
  845. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  846. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  847. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  848. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  849. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  850. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  851. }
  852. };
  853. /**
  854. * Marks the texture as dirty forcing a complete update
  855. */
  856. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  857. this._isDirty = true;
  858. };
  859. /**
  860. * Helper function used to create a new style
  861. * @returns a new style
  862. * @see http://doc.babylonjs.com/how_to/gui#styles
  863. */
  864. AdvancedDynamicTexture.prototype.createStyle = function () {
  865. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  866. };
  867. /**
  868. * Adds a new control to the root container
  869. * @param control defines the control to add
  870. * @returns the current texture
  871. */
  872. AdvancedDynamicTexture.prototype.addControl = function (control) {
  873. this._rootContainer.addControl(control);
  874. return this;
  875. };
  876. /**
  877. * Removes a control from the root container
  878. * @param control defines the control to remove
  879. * @returns the current texture
  880. */
  881. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  882. this._rootContainer.removeControl(control);
  883. return this;
  884. };
  885. /**
  886. * Release all resources
  887. */
  888. AdvancedDynamicTexture.prototype.dispose = function () {
  889. var scene = this.getScene();
  890. if (!scene) {
  891. return;
  892. }
  893. this._rootCanvas = null;
  894. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  895. if (this._resizeObserver) {
  896. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  897. }
  898. if (this._pointerMoveObserver) {
  899. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  900. }
  901. if (this._pointerObserver) {
  902. scene.onPointerObservable.remove(this._pointerObserver);
  903. }
  904. if (this._preKeyboardObserver) {
  905. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  906. }
  907. if (this._canvasPointerOutObserver) {
  908. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  909. }
  910. if (this._layerToDispose) {
  911. this._layerToDispose.texture = null;
  912. this._layerToDispose.dispose();
  913. this._layerToDispose = null;
  914. }
  915. this._rootContainer.dispose();
  916. this.onClipboardObservable.clear();
  917. this.onControlPickedObservable.clear();
  918. this.onBeginRenderObservable.clear();
  919. this.onEndRenderObservable.clear();
  920. this.onBeginLayoutObservable.clear();
  921. this.onEndLayoutObservable.clear();
  922. _super.prototype.dispose.call(this);
  923. };
  924. AdvancedDynamicTexture.prototype._onResize = function () {
  925. var scene = this.getScene();
  926. if (!scene) {
  927. return;
  928. }
  929. // Check size
  930. var engine = scene.getEngine();
  931. var textureSize = this.getSize();
  932. var renderWidth = engine.getRenderWidth() * this._renderScale;
  933. var renderHeight = engine.getRenderHeight() * this._renderScale;
  934. if (this._renderAtIdealSize) {
  935. if (this._idealWidth) {
  936. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  937. renderWidth = this._idealWidth;
  938. }
  939. else if (this._idealHeight) {
  940. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  941. renderHeight = this._idealHeight;
  942. }
  943. }
  944. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  945. this.scaleTo(renderWidth, renderHeight);
  946. this.markAsDirty();
  947. if (this._idealWidth || this._idealHeight) {
  948. this._rootContainer._markAllAsDirty();
  949. }
  950. }
  951. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  952. };
  953. /** @hidden */
  954. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  955. var engine = scene.getEngine();
  956. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  957. };
  958. /**
  959. * Get screen coordinates for a vector3
  960. * @param position defines the position to project
  961. * @param worldMatrix defines the world matrix to use
  962. * @returns the projected position
  963. */
  964. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  965. var scene = this.getScene();
  966. if (!scene) {
  967. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  968. }
  969. var globalViewport = this._getGlobalViewport(scene);
  970. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  971. projectedPosition.scaleInPlace(this.renderScale);
  972. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  973. };
  974. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  975. if (this._layerToDispose) {
  976. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  977. return;
  978. }
  979. }
  980. if (this._isFullscreen && this._linkedControls.length) {
  981. var scene = this.getScene();
  982. if (!scene) {
  983. return;
  984. }
  985. var globalViewport = this._getGlobalViewport(scene);
  986. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  987. var control = _a[_i];
  988. if (!control.isVisible) {
  989. continue;
  990. }
  991. var mesh = control._linkedMesh;
  992. if (!mesh || mesh.isDisposed()) {
  993. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  994. control.linkWithMesh(null);
  995. });
  996. continue;
  997. }
  998. var position = mesh.getBoundingInfo().boundingSphere.center;
  999. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1000. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1001. control.notRenderable = true;
  1002. continue;
  1003. }
  1004. control.notRenderable = false;
  1005. // Account for RenderScale.
  1006. projectedPosition.scaleInPlace(this.renderScale);
  1007. control._moveToProjectedPosition(projectedPosition);
  1008. }
  1009. }
  1010. if (!this._isDirty && !this._rootContainer.isDirty) {
  1011. return;
  1012. }
  1013. this._isDirty = false;
  1014. this._render();
  1015. this.update(true, this.premulAlpha);
  1016. };
  1017. AdvancedDynamicTexture.prototype._render = function () {
  1018. var textureSize = this.getSize();
  1019. var renderWidth = textureSize.width;
  1020. var renderHeight = textureSize.height;
  1021. var context = this.getContext();
  1022. context.font = "18px Arial";
  1023. context.strokeStyle = "white";
  1024. // Layout
  1025. this.onBeginLayoutObservable.notifyObservers(this);
  1026. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1027. this._rootContainer._layout(measure, context);
  1028. this.onEndLayoutObservable.notifyObservers(this);
  1029. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1030. // Clear
  1031. if (this._invalidatedRectangle) {
  1032. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1033. }
  1034. else {
  1035. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1036. }
  1037. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1038. if (this._background) {
  1039. context.save();
  1040. context.fillStyle = this._background;
  1041. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1042. context.restore();
  1043. }
  1044. // Render
  1045. this.onBeginRenderObservable.notifyObservers(this);
  1046. this._rootContainer._render(context, this._invalidatedRectangle);
  1047. this.onEndRenderObservable.notifyObservers(this);
  1048. this._invalidatedRectangle = null;
  1049. };
  1050. /** @hidden */
  1051. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1052. if (this._rootCanvas) {
  1053. this._rootCanvas.style.cursor = cursor;
  1054. }
  1055. };
  1056. /** @hidden */
  1057. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1058. this._lastControlDown[pointerId] = control;
  1059. this.onControlPickedObservable.notifyObservers(control);
  1060. };
  1061. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1062. var scene = this.getScene();
  1063. if (!scene) {
  1064. return;
  1065. }
  1066. var engine = scene.getEngine();
  1067. var textureSize = this.getSize();
  1068. if (this._isFullscreen) {
  1069. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1070. var viewport = camera.viewport;
  1071. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1072. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1073. }
  1074. if (this._capturingControl[pointerId]) {
  1075. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1076. return;
  1077. }
  1078. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1079. this._changeCursor("");
  1080. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1081. if (this._lastControlOver[pointerId]) {
  1082. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1083. delete this._lastControlOver[pointerId];
  1084. }
  1085. }
  1086. }
  1087. this._manageFocus();
  1088. };
  1089. /** @hidden */
  1090. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1091. for (var pointerId in list) {
  1092. if (!list.hasOwnProperty(pointerId)) {
  1093. continue;
  1094. }
  1095. var lastControlOver = list[pointerId];
  1096. if (lastControlOver === control) {
  1097. delete list[pointerId];
  1098. }
  1099. }
  1100. };
  1101. /** @hidden */
  1102. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1103. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1104. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1105. };
  1106. /** Attach to all scene events required to support pointer events */
  1107. AdvancedDynamicTexture.prototype.attach = function () {
  1108. var _this = this;
  1109. var scene = this.getScene();
  1110. if (!scene) {
  1111. return;
  1112. }
  1113. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1114. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1115. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1116. return;
  1117. }
  1118. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1119. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1120. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1121. return;
  1122. }
  1123. if (!scene) {
  1124. return;
  1125. }
  1126. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1127. var engine = scene.getEngine();
  1128. if (!camera) {
  1129. tempViewport.x = 0;
  1130. tempViewport.y = 0;
  1131. tempViewport.width = engine.getRenderWidth();
  1132. tempViewport.height = engine.getRenderHeight();
  1133. }
  1134. else {
  1135. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1136. }
  1137. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1138. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1139. _this._shouldBlockPointer = false;
  1140. // Do picking modifies _shouldBlockPointer
  1141. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1142. // Avoid overwriting a true skipOnPointerObservable to false
  1143. if (_this._shouldBlockPointer) {
  1144. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1145. }
  1146. });
  1147. this._attachToOnPointerOut(scene);
  1148. };
  1149. /**
  1150. * Register the clipboard Events onto the canvas
  1151. */
  1152. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1153. self.addEventListener("copy", this.onClipboardCopy, false);
  1154. self.addEventListener("cut", this.onClipboardCut, false);
  1155. self.addEventListener("paste", this.onClipboardPaste, false);
  1156. };
  1157. /**
  1158. * Unregister the clipboard Events from the canvas
  1159. */
  1160. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1161. self.removeEventListener("copy", this.onClipboardCopy);
  1162. self.removeEventListener("cut", this.onClipboardCut);
  1163. self.removeEventListener("paste", this.onClipboardPaste);
  1164. };
  1165. /**
  1166. * Connect the texture to a hosting mesh to enable interactions
  1167. * @param mesh defines the mesh to attach to
  1168. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1169. */
  1170. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1171. var _this = this;
  1172. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1173. var scene = this.getScene();
  1174. if (!scene) {
  1175. return;
  1176. }
  1177. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1178. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1179. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1180. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1181. return;
  1182. }
  1183. var pointerId = pi.event.pointerId || 0;
  1184. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1185. var uv = pi.pickInfo.getTextureCoordinates();
  1186. if (uv) {
  1187. var size = _this.getSize();
  1188. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1189. }
  1190. }
  1191. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1192. if (_this._lastControlDown[pointerId]) {
  1193. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1194. }
  1195. delete _this._lastControlDown[pointerId];
  1196. if (_this.focusedControl) {
  1197. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1198. var canMoveFocus = true;
  1199. if (friendlyControls) {
  1200. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1201. var control = friendlyControls_1[_i];
  1202. // Same host, no need to keep the focus
  1203. if (_this === control._host) {
  1204. continue;
  1205. }
  1206. // Different hosts
  1207. var otherHost = control._host;
  1208. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1209. canMoveFocus = false;
  1210. break;
  1211. }
  1212. }
  1213. }
  1214. if (canMoveFocus) {
  1215. _this.focusedControl = null;
  1216. }
  1217. }
  1218. }
  1219. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1220. if (_this._lastControlOver[pointerId]) {
  1221. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId]);
  1222. }
  1223. delete _this._lastControlOver[pointerId];
  1224. }
  1225. });
  1226. mesh.enablePointerMoveEvents = supportPointerMove;
  1227. this._attachToOnPointerOut(scene);
  1228. };
  1229. /**
  1230. * Move the focus to a specific control
  1231. * @param control defines the control which will receive the focus
  1232. */
  1233. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1234. this.focusedControl = control;
  1235. this._lastPickedControl = control;
  1236. this._blockNextFocusCheck = true;
  1237. };
  1238. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1239. if (this._blockNextFocusCheck) {
  1240. this._blockNextFocusCheck = false;
  1241. this._lastPickedControl = this._focusedControl;
  1242. return;
  1243. }
  1244. // Focus management
  1245. if (this._focusedControl) {
  1246. if (this._focusedControl !== this._lastPickedControl) {
  1247. if (this._lastPickedControl.isFocusInvisible) {
  1248. return;
  1249. }
  1250. this.focusedControl = null;
  1251. }
  1252. }
  1253. };
  1254. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1255. var _this = this;
  1256. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1257. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1258. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1259. }
  1260. delete _this._lastControlOver[pointerEvent.pointerId];
  1261. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1262. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1263. delete _this._lastControlDown[pointerEvent.pointerId];
  1264. }
  1265. });
  1266. };
  1267. // Statics
  1268. /**
  1269. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1270. * @param mesh defines the mesh which will receive the texture
  1271. * @param width defines the texture width (1024 by default)
  1272. * @param height defines the texture height (1024 by default)
  1273. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1274. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1275. * @returns a new AdvancedDynamicTexture
  1276. */
  1277. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1278. if (width === void 0) { width = 1024; }
  1279. if (height === void 0) { height = 1024; }
  1280. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1281. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1282. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1283. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1284. material.backFaceCulling = false;
  1285. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1286. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1287. if (onlyAlphaTesting) {
  1288. material.diffuseTexture = result;
  1289. material.emissiveTexture = result;
  1290. result.hasAlpha = true;
  1291. }
  1292. else {
  1293. material.emissiveTexture = result;
  1294. material.opacityTexture = result;
  1295. }
  1296. mesh.material = material;
  1297. result.attachToMesh(mesh, supportPointerMove);
  1298. return result;
  1299. };
  1300. /**
  1301. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1302. * In this mode the texture will rely on a layer for its rendering.
  1303. * This allows it to be treated like any other layer.
  1304. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1305. * LayerMask is set through advancedTexture.layer.layerMask
  1306. * @param name defines name for the texture
  1307. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1308. * @param scene defines the hsoting scene
  1309. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1310. * @returns a new AdvancedDynamicTexture
  1311. */
  1312. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1313. if (foreground === void 0) { foreground = true; }
  1314. if (scene === void 0) { scene = null; }
  1315. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1316. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1317. // Display
  1318. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1319. layer.texture = result;
  1320. result._layerToDispose = layer;
  1321. result._isFullscreen = true;
  1322. // Attach
  1323. result.attach();
  1324. return result;
  1325. };
  1326. return AdvancedDynamicTexture;
  1327. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1328. /***/ }),
  1329. /***/ "./2D/controls/button.ts":
  1330. /*!*******************************!*\
  1331. !*** ./2D/controls/button.ts ***!
  1332. \*******************************/
  1333. /*! exports provided: Button */
  1334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1335. "use strict";
  1336. __webpack_require__.r(__webpack_exports__);
  1337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1338. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1339. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1340. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1341. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1342. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1343. /**
  1344. * Class used to create 2D buttons
  1345. */
  1346. var Button = /** @class */ (function (_super) {
  1347. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1348. /**
  1349. * Creates a new Button
  1350. * @param name defines the name of the button
  1351. */
  1352. function Button(name) {
  1353. var _this = _super.call(this, name) || this;
  1354. _this.name = name;
  1355. _this.thickness = 1;
  1356. _this.isPointerBlocker = true;
  1357. var alphaStore = null;
  1358. _this.pointerEnterAnimation = function () {
  1359. alphaStore = _this.alpha;
  1360. _this.alpha -= 0.1;
  1361. };
  1362. _this.pointerOutAnimation = function () {
  1363. if (alphaStore !== null) {
  1364. _this.alpha = alphaStore;
  1365. }
  1366. };
  1367. _this.pointerDownAnimation = function () {
  1368. _this.scaleX -= 0.05;
  1369. _this.scaleY -= 0.05;
  1370. };
  1371. _this.pointerUpAnimation = function () {
  1372. _this.scaleX += 0.05;
  1373. _this.scaleY += 0.05;
  1374. };
  1375. return _this;
  1376. }
  1377. Object.defineProperty(Button.prototype, "image", {
  1378. /**
  1379. * Returns the image part of the button (if any)
  1380. */
  1381. get: function () {
  1382. return this._image;
  1383. },
  1384. enumerable: true,
  1385. configurable: true
  1386. });
  1387. Object.defineProperty(Button.prototype, "textBlock", {
  1388. /**
  1389. * Returns the image part of the button (if any)
  1390. */
  1391. get: function () {
  1392. return this._textBlock;
  1393. },
  1394. enumerable: true,
  1395. configurable: true
  1396. });
  1397. Button.prototype._getTypeName = function () {
  1398. return "Button";
  1399. };
  1400. // While being a container, the button behaves like a control.
  1401. /** @hidden */
  1402. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1403. if (!this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1404. return false;
  1405. }
  1406. if (!_super.prototype.contains.call(this, x, y)) {
  1407. return false;
  1408. }
  1409. this._processObservables(type, x, y, pointerId, buttonIndex);
  1410. return true;
  1411. };
  1412. /** @hidden */
  1413. Button.prototype._onPointerEnter = function (target) {
  1414. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1415. return false;
  1416. }
  1417. if (this.pointerEnterAnimation) {
  1418. this.pointerEnterAnimation();
  1419. }
  1420. return true;
  1421. };
  1422. /** @hidden */
  1423. Button.prototype._onPointerOut = function (target) {
  1424. if (this.pointerOutAnimation) {
  1425. this.pointerOutAnimation();
  1426. }
  1427. _super.prototype._onPointerOut.call(this, target);
  1428. };
  1429. /** @hidden */
  1430. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1431. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1432. return false;
  1433. }
  1434. if (this.pointerDownAnimation) {
  1435. this.pointerDownAnimation();
  1436. }
  1437. return true;
  1438. };
  1439. /** @hidden */
  1440. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1441. if (this.pointerUpAnimation) {
  1442. this.pointerUpAnimation();
  1443. }
  1444. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1445. };
  1446. // Statics
  1447. /**
  1448. * Creates a new button made with an image and a text
  1449. * @param name defines the name of the button
  1450. * @param text defines the text of the button
  1451. * @param imageUrl defines the url of the image
  1452. * @returns a new Button
  1453. */
  1454. Button.CreateImageButton = function (name, text, imageUrl) {
  1455. var result = new Button(name);
  1456. // Adding text
  1457. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1458. textBlock.textWrapping = true;
  1459. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1460. textBlock.paddingLeft = "20%";
  1461. result.addControl(textBlock);
  1462. // Adding image
  1463. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1464. iconImage.width = "20%";
  1465. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1466. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1467. result.addControl(iconImage);
  1468. // Store
  1469. result._image = iconImage;
  1470. result._textBlock = textBlock;
  1471. return result;
  1472. };
  1473. /**
  1474. * Creates a new button made with an image
  1475. * @param name defines the name of the button
  1476. * @param imageUrl defines the url of the image
  1477. * @returns a new Button
  1478. */
  1479. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1480. var result = new Button(name);
  1481. // Adding image
  1482. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1483. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1484. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1485. result.addControl(iconImage);
  1486. // Store
  1487. result._image = iconImage;
  1488. return result;
  1489. };
  1490. /**
  1491. * Creates a new button made with a text
  1492. * @param name defines the name of the button
  1493. * @param text defines the text of the button
  1494. * @returns a new Button
  1495. */
  1496. Button.CreateSimpleButton = function (name, text) {
  1497. var result = new Button(name);
  1498. // Adding text
  1499. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1500. textBlock.textWrapping = true;
  1501. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1502. result.addControl(textBlock);
  1503. // Store
  1504. result._textBlock = textBlock;
  1505. return result;
  1506. };
  1507. /**
  1508. * Creates a new button made with an image and a centered text
  1509. * @param name defines the name of the button
  1510. * @param text defines the text of the button
  1511. * @param imageUrl defines the url of the image
  1512. * @returns a new Button
  1513. */
  1514. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1515. var result = new Button(name);
  1516. // Adding image
  1517. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1518. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1519. result.addControl(iconImage);
  1520. // Adding text
  1521. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1522. textBlock.textWrapping = true;
  1523. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1524. result.addControl(textBlock);
  1525. // Store
  1526. result._image = iconImage;
  1527. result._textBlock = textBlock;
  1528. return result;
  1529. };
  1530. return Button;
  1531. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1532. /***/ }),
  1533. /***/ "./2D/controls/checkbox.ts":
  1534. /*!*********************************!*\
  1535. !*** ./2D/controls/checkbox.ts ***!
  1536. \*********************************/
  1537. /*! exports provided: Checkbox */
  1538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1539. "use strict";
  1540. __webpack_require__.r(__webpack_exports__);
  1541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1542. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1543. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1544. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1545. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1546. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1547. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1548. /**
  1549. * Class used to represent a 2D checkbox
  1550. */
  1551. var Checkbox = /** @class */ (function (_super) {
  1552. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1553. /**
  1554. * Creates a new CheckBox
  1555. * @param name defines the control name
  1556. */
  1557. function Checkbox(name) {
  1558. var _this = _super.call(this, name) || this;
  1559. _this.name = name;
  1560. _this._isChecked = false;
  1561. _this._background = "black";
  1562. _this._checkSizeRatio = 0.8;
  1563. _this._thickness = 1;
  1564. /**
  1565. * Observable raised when isChecked property changes
  1566. */
  1567. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1568. _this.isPointerBlocker = true;
  1569. return _this;
  1570. }
  1571. Object.defineProperty(Checkbox.prototype, "thickness", {
  1572. /** Gets or sets border thickness */
  1573. get: function () {
  1574. return this._thickness;
  1575. },
  1576. set: function (value) {
  1577. if (this._thickness === value) {
  1578. return;
  1579. }
  1580. this._thickness = value;
  1581. this._markAsDirty();
  1582. },
  1583. enumerable: true,
  1584. configurable: true
  1585. });
  1586. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1587. /** Gets or sets a value indicating the ratio between overall size and check size */
  1588. get: function () {
  1589. return this._checkSizeRatio;
  1590. },
  1591. set: function (value) {
  1592. value = Math.max(Math.min(1, value), 0);
  1593. if (this._checkSizeRatio === value) {
  1594. return;
  1595. }
  1596. this._checkSizeRatio = value;
  1597. this._markAsDirty();
  1598. },
  1599. enumerable: true,
  1600. configurable: true
  1601. });
  1602. Object.defineProperty(Checkbox.prototype, "background", {
  1603. /** Gets or sets background color */
  1604. get: function () {
  1605. return this._background;
  1606. },
  1607. set: function (value) {
  1608. if (this._background === value) {
  1609. return;
  1610. }
  1611. this._background = value;
  1612. this._markAsDirty();
  1613. },
  1614. enumerable: true,
  1615. configurable: true
  1616. });
  1617. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1618. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1619. get: function () {
  1620. return this._isChecked;
  1621. },
  1622. set: function (value) {
  1623. if (this._isChecked === value) {
  1624. return;
  1625. }
  1626. this._isChecked = value;
  1627. this._markAsDirty();
  1628. this.onIsCheckedChangedObservable.notifyObservers(value);
  1629. },
  1630. enumerable: true,
  1631. configurable: true
  1632. });
  1633. Checkbox.prototype._getTypeName = function () {
  1634. return "Checkbox";
  1635. };
  1636. /** @hidden */
  1637. Checkbox.prototype._draw = function (context) {
  1638. context.save();
  1639. this._applyStates(context);
  1640. var actualWidth = this._currentMeasure.width - this._thickness;
  1641. var actualHeight = this._currentMeasure.height - this._thickness;
  1642. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1643. context.shadowColor = this.shadowColor;
  1644. context.shadowBlur = this.shadowBlur;
  1645. context.shadowOffsetX = this.shadowOffsetX;
  1646. context.shadowOffsetY = this.shadowOffsetY;
  1647. }
  1648. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1649. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1650. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1651. context.shadowBlur = 0;
  1652. context.shadowOffsetX = 0;
  1653. context.shadowOffsetY = 0;
  1654. }
  1655. if (this._isChecked) {
  1656. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1657. var offsetWidth = actualWidth * this._checkSizeRatio;
  1658. var offseHeight = actualHeight * this._checkSizeRatio;
  1659. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1660. }
  1661. context.strokeStyle = this.color;
  1662. context.lineWidth = this._thickness;
  1663. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1664. context.restore();
  1665. };
  1666. // Events
  1667. /** @hidden */
  1668. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1669. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1670. return false;
  1671. }
  1672. this.isChecked = !this.isChecked;
  1673. return true;
  1674. };
  1675. /**
  1676. * Utility function to easily create a checkbox with a header
  1677. * @param title defines the label to use for the header
  1678. * @param onValueChanged defines the callback to call when value changes
  1679. * @returns a StackPanel containing the checkbox and a textBlock
  1680. */
  1681. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1682. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1683. panel.isVertical = false;
  1684. panel.height = "30px";
  1685. var checkbox = new Checkbox();
  1686. checkbox.width = "20px";
  1687. checkbox.height = "20px";
  1688. checkbox.isChecked = true;
  1689. checkbox.color = "green";
  1690. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1691. panel.addControl(checkbox);
  1692. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1693. header.text = title;
  1694. header.width = "180px";
  1695. header.paddingLeft = "5px";
  1696. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1697. header.color = "white";
  1698. panel.addControl(header);
  1699. return panel;
  1700. };
  1701. return Checkbox;
  1702. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1703. /***/ }),
  1704. /***/ "./2D/controls/colorpicker.ts":
  1705. /*!************************************!*\
  1706. !*** ./2D/controls/colorpicker.ts ***!
  1707. \************************************/
  1708. /*! exports provided: ColorPicker */
  1709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1710. "use strict";
  1711. __webpack_require__.r(__webpack_exports__);
  1712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1713. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1714. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1715. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1716. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1717. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1718. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1719. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1720. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1721. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1722. /** Class used to create color pickers */
  1723. var ColorPicker = /** @class */ (function (_super) {
  1724. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1725. /**
  1726. * Creates a new ColorPicker
  1727. * @param name defines the control name
  1728. */
  1729. function ColorPicker(name) {
  1730. var _this = _super.call(this, name) || this;
  1731. _this.name = name;
  1732. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1733. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1734. _this._pointerStartedOnSquare = false;
  1735. _this._pointerStartedOnWheel = false;
  1736. _this._squareLeft = 0;
  1737. _this._squareTop = 0;
  1738. _this._squareSize = 0;
  1739. _this._h = 360;
  1740. _this._s = 1;
  1741. _this._v = 1;
  1742. /**
  1743. * Observable raised when the value changes
  1744. */
  1745. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1746. // Events
  1747. _this._pointerIsDown = false;
  1748. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1749. _this.size = "200px";
  1750. _this.isPointerBlocker = true;
  1751. return _this;
  1752. }
  1753. Object.defineProperty(ColorPicker.prototype, "value", {
  1754. /** Gets or sets the color of the color picker */
  1755. get: function () {
  1756. return this._value;
  1757. },
  1758. set: function (value) {
  1759. if (this._value.equals(value)) {
  1760. return;
  1761. }
  1762. this._value.copyFrom(value);
  1763. this._RGBtoHSV(this._value, this._tmpColor);
  1764. this._h = this._tmpColor.r;
  1765. this._s = Math.max(this._tmpColor.g, 0.00001);
  1766. this._v = Math.max(this._tmpColor.b, 0.00001);
  1767. this._markAsDirty();
  1768. if (this._value.r <= ColorPicker._Epsilon) {
  1769. this._value.r = 0;
  1770. }
  1771. if (this._value.g <= ColorPicker._Epsilon) {
  1772. this._value.g = 0;
  1773. }
  1774. if (this._value.b <= ColorPicker._Epsilon) {
  1775. this._value.b = 0;
  1776. }
  1777. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1778. this._value.r = 1.0;
  1779. }
  1780. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1781. this._value.g = 1.0;
  1782. }
  1783. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1784. this._value.b = 1.0;
  1785. }
  1786. this.onValueChangedObservable.notifyObservers(this._value);
  1787. },
  1788. enumerable: true,
  1789. configurable: true
  1790. });
  1791. Object.defineProperty(ColorPicker.prototype, "width", {
  1792. /**
  1793. * Gets or sets control width
  1794. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1795. */
  1796. get: function () {
  1797. return this._width.toString(this._host);
  1798. },
  1799. set: function (value) {
  1800. if (this._width.toString(this._host) === value) {
  1801. return;
  1802. }
  1803. if (this._width.fromString(value)) {
  1804. this._height.fromString(value);
  1805. this._markAsDirty();
  1806. }
  1807. },
  1808. enumerable: true,
  1809. configurable: true
  1810. });
  1811. Object.defineProperty(ColorPicker.prototype, "height", {
  1812. /**
  1813. * Gets or sets control height
  1814. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1815. */
  1816. get: function () {
  1817. return this._height.toString(this._host);
  1818. },
  1819. /** Gets or sets control height */
  1820. set: function (value) {
  1821. if (this._height.toString(this._host) === value) {
  1822. return;
  1823. }
  1824. if (this._height.fromString(value)) {
  1825. this._width.fromString(value);
  1826. this._markAsDirty();
  1827. }
  1828. },
  1829. enumerable: true,
  1830. configurable: true
  1831. });
  1832. Object.defineProperty(ColorPicker.prototype, "size", {
  1833. /** Gets or sets control size */
  1834. get: function () {
  1835. return this.width;
  1836. },
  1837. set: function (value) {
  1838. this.width = value;
  1839. },
  1840. enumerable: true,
  1841. configurable: true
  1842. });
  1843. ColorPicker.prototype._getTypeName = function () {
  1844. return "ColorPicker";
  1845. };
  1846. /** @hidden */
  1847. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1848. if (parentMeasure.width < parentMeasure.height) {
  1849. this._currentMeasure.height = parentMeasure.width;
  1850. }
  1851. else {
  1852. this._currentMeasure.width = parentMeasure.height;
  1853. }
  1854. };
  1855. ColorPicker.prototype._updateSquareProps = function () {
  1856. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1857. var wheelThickness = radius * .2;
  1858. var innerDiameter = (radius - wheelThickness) * 2;
  1859. var squareSize = innerDiameter / (Math.sqrt(2));
  1860. var offset = radius - squareSize * .5;
  1861. this._squareLeft = this._currentMeasure.left + offset;
  1862. this._squareTop = this._currentMeasure.top + offset;
  1863. this._squareSize = squareSize;
  1864. };
  1865. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1866. var lgh = context.createLinearGradient(left, top, width + left, top);
  1867. lgh.addColorStop(0, '#fff');
  1868. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1869. context.fillStyle = lgh;
  1870. context.fillRect(left, top, width, height);
  1871. var lgv = context.createLinearGradient(left, top, left, height + top);
  1872. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1873. lgv.addColorStop(1, '#000');
  1874. context.fillStyle = lgv;
  1875. context.fillRect(left, top, width, height);
  1876. };
  1877. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1878. context.beginPath();
  1879. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1880. context.lineWidth = 3;
  1881. context.strokeStyle = '#333333';
  1882. context.stroke();
  1883. context.beginPath();
  1884. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1885. context.lineWidth = 3;
  1886. context.strokeStyle = '#ffffff';
  1887. context.stroke();
  1888. };
  1889. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1890. var canvas = document.createElement("canvas");
  1891. canvas.width = radius * 2;
  1892. canvas.height = radius * 2;
  1893. var context = canvas.getContext("2d");
  1894. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1895. var data = image.data;
  1896. var color = this._tmpColor;
  1897. var maxDistSq = radius * radius;
  1898. var innerRadius = radius - thickness;
  1899. var minDistSq = innerRadius * innerRadius;
  1900. for (var x = -radius; x < radius; x++) {
  1901. for (var y = -radius; y < radius; y++) {
  1902. var distSq = x * x + y * y;
  1903. if (distSq > maxDistSq || distSq < minDistSq) {
  1904. continue;
  1905. }
  1906. var dist = Math.sqrt(distSq);
  1907. var ang = Math.atan2(y, x);
  1908. this._HSVtoRGB(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1909. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1910. data[index] = color.r * 255;
  1911. data[index + 1] = color.g * 255;
  1912. data[index + 2] = color.b * 255;
  1913. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1914. //apply less alpha to bigger color pickers
  1915. var alphaAmount = .2;
  1916. var maxAlpha = .2;
  1917. var minAlpha = .04;
  1918. var lowerRadius = 50;
  1919. var upperRadius = 150;
  1920. if (radius < lowerRadius) {
  1921. alphaAmount = maxAlpha;
  1922. }
  1923. else if (radius > upperRadius) {
  1924. alphaAmount = minAlpha;
  1925. }
  1926. else {
  1927. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1928. }
  1929. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1930. if (alphaRatio < alphaAmount) {
  1931. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1932. }
  1933. else if (alphaRatio > 1 - alphaAmount) {
  1934. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1935. }
  1936. else {
  1937. data[index + 3] = 255;
  1938. }
  1939. }
  1940. }
  1941. context.putImageData(image, 0, 0);
  1942. return canvas;
  1943. };
  1944. ColorPicker.prototype._RGBtoHSV = function (color, result) {
  1945. var r = color.r;
  1946. var g = color.g;
  1947. var b = color.b;
  1948. var max = Math.max(r, g, b);
  1949. var min = Math.min(r, g, b);
  1950. var h = 0;
  1951. var s = 0;
  1952. var v = max;
  1953. var dm = max - min;
  1954. if (max !== 0) {
  1955. s = dm / max;
  1956. }
  1957. if (max != min) {
  1958. if (max == r) {
  1959. h = (g - b) / dm;
  1960. if (g < b) {
  1961. h += 6;
  1962. }
  1963. }
  1964. else if (max == g) {
  1965. h = (b - r) / dm + 2;
  1966. }
  1967. else if (max == b) {
  1968. h = (r - g) / dm + 4;
  1969. }
  1970. h *= 60;
  1971. }
  1972. result.r = h;
  1973. result.g = s;
  1974. result.b = v;
  1975. };
  1976. ColorPicker.prototype._HSVtoRGB = function (hue, saturation, value, result) {
  1977. var chroma = value * saturation;
  1978. var h = hue / 60;
  1979. var x = chroma * (1 - Math.abs((h % 2) - 1));
  1980. var r = 0;
  1981. var g = 0;
  1982. var b = 0;
  1983. if (h >= 0 && h <= 1) {
  1984. r = chroma;
  1985. g = x;
  1986. }
  1987. else if (h >= 1 && h <= 2) {
  1988. r = x;
  1989. g = chroma;
  1990. }
  1991. else if (h >= 2 && h <= 3) {
  1992. g = chroma;
  1993. b = x;
  1994. }
  1995. else if (h >= 3 && h <= 4) {
  1996. g = x;
  1997. b = chroma;
  1998. }
  1999. else if (h >= 4 && h <= 5) {
  2000. r = x;
  2001. b = chroma;
  2002. }
  2003. else if (h >= 5 && h <= 6) {
  2004. r = chroma;
  2005. b = x;
  2006. }
  2007. var m = value - chroma;
  2008. result.set((r + m), (g + m), (b + m));
  2009. };
  2010. /** @hidden */
  2011. ColorPicker.prototype._draw = function (context) {
  2012. context.save();
  2013. this._applyStates(context);
  2014. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2015. var wheelThickness = radius * .2;
  2016. var left = this._currentMeasure.left;
  2017. var top = this._currentMeasure.top;
  2018. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2019. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2020. }
  2021. this._updateSquareProps();
  2022. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2023. context.shadowColor = this.shadowColor;
  2024. context.shadowBlur = this.shadowBlur;
  2025. context.shadowOffsetX = this.shadowOffsetX;
  2026. context.shadowOffsetY = this.shadowOffsetY;
  2027. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2028. }
  2029. context.drawImage(this._colorWheelCanvas, left, top);
  2030. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2031. context.shadowBlur = 0;
  2032. context.shadowOffsetX = 0;
  2033. context.shadowOffsetY = 0;
  2034. }
  2035. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2036. var cx = this._squareLeft + this._squareSize * this._s;
  2037. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2038. this._drawCircle(cx, cy, radius * .04, context);
  2039. var dist = radius - wheelThickness * .5;
  2040. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2041. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2042. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2043. context.restore();
  2044. };
  2045. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2046. if (this._pointerStartedOnWheel) {
  2047. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2048. var centerX = radius + this._currentMeasure.left;
  2049. var centerY = radius + this._currentMeasure.top;
  2050. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2051. }
  2052. else if (this._pointerStartedOnSquare) {
  2053. this._updateSquareProps();
  2054. this._s = (x - this._squareLeft) / this._squareSize;
  2055. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2056. this._s = Math.min(this._s, 1);
  2057. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2058. this._v = Math.min(this._v, 1);
  2059. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2060. }
  2061. this._HSVtoRGB(this._h, this._s, this._v, this._tmpColor);
  2062. this.value = this._tmpColor;
  2063. };
  2064. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2065. this._updateSquareProps();
  2066. var left = this._squareLeft;
  2067. var top = this._squareTop;
  2068. var size = this._squareSize;
  2069. if (x >= left && x <= left + size &&
  2070. y >= top && y <= top + size) {
  2071. return true;
  2072. }
  2073. return false;
  2074. };
  2075. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2076. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2077. var centerX = radius + this._currentMeasure.left;
  2078. var centerY = radius + this._currentMeasure.top;
  2079. var wheelThickness = radius * .2;
  2080. var innerRadius = radius - wheelThickness;
  2081. var radiusSq = radius * radius;
  2082. var innerRadiusSq = innerRadius * innerRadius;
  2083. var dx = x - centerX;
  2084. var dy = y - centerY;
  2085. var distSq = dx * dx + dy * dy;
  2086. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2087. return true;
  2088. }
  2089. return false;
  2090. };
  2091. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2092. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2093. return false;
  2094. }
  2095. this._pointerIsDown = true;
  2096. this._pointerStartedOnSquare = false;
  2097. this._pointerStartedOnWheel = false;
  2098. // Invert transform
  2099. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2100. var x = this._transformedPosition.x;
  2101. var y = this._transformedPosition.y;
  2102. if (this._isPointOnSquare(x, y)) {
  2103. this._pointerStartedOnSquare = true;
  2104. }
  2105. else if (this._isPointOnWheel(x, y)) {
  2106. this._pointerStartedOnWheel = true;
  2107. }
  2108. this._updateValueFromPointer(x, y);
  2109. this._host._capturingControl[pointerId] = this;
  2110. return true;
  2111. };
  2112. ColorPicker.prototype._onPointerMove = function (target, coordinates) {
  2113. // Invert transform
  2114. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2115. var x = this._transformedPosition.x;
  2116. var y = this._transformedPosition.y;
  2117. if (this._pointerIsDown) {
  2118. this._updateValueFromPointer(x, y);
  2119. }
  2120. _super.prototype._onPointerMove.call(this, target, coordinates);
  2121. };
  2122. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2123. this._pointerIsDown = false;
  2124. delete this._host._capturingControl[pointerId];
  2125. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2126. };
  2127. /**
  2128. * This function expands the color picker by creating a color picker dialog with manual
  2129. * color value input and the ability to save colors into an array to be used later in
  2130. * subsequent launches of the dialogue.
  2131. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2132. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  2133. * @returns picked color as a hex string and the saved colors array as hex strings.
  2134. */
  2135. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2136. return new Promise(function (resolve, reject) {
  2137. // Default options
  2138. options.pickerWidth = options.pickerWidth || "640px";
  2139. options.pickerHeight = options.pickerHeight || "400px";
  2140. options.headerHeight = options.headerHeight || "35px";
  2141. options.lastColor = options.lastColor || "#000000";
  2142. options.swatchLimit = options.swatchLimit || 20;
  2143. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2144. // Window size settings
  2145. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2146. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2147. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2148. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2149. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2150. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2151. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2152. // Button Colors
  2153. var buttonColor = "#c0c0c0";
  2154. var buttonBackgroundColor = "#535353";
  2155. var buttonBackgroundHoverColor = "#414141";
  2156. var buttonBackgroundClickColor = "515151";
  2157. var buttonDisabledColor = "#555555";
  2158. var buttonDisabledBackgroundColor = "#454545";
  2159. var currentSwatchesOutlineColor = "#404040";
  2160. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2161. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2162. var iconColorDark = "#aaaaaa";
  2163. var iconColorLight = "#ffffff";
  2164. var closeIconColor;
  2165. // Button settings
  2166. var buttonFontSize;
  2167. var butEdit;
  2168. var buttonWidth;
  2169. var buttonHeight;
  2170. // Input Text Colors
  2171. var inputFieldLabels = ["R", "G", "B"];
  2172. var inputTextBackgroundColor = "#454545";
  2173. var inputTextColor = "#f0f0f0";
  2174. // This is the current color as set by either the picker or by entering a value
  2175. var currentColor;
  2176. // This int is used for naming swatches and serves as the index for calling them from the list
  2177. var swatchNumber;
  2178. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2179. var swatchDrawer;
  2180. var editSwatchMode = false;
  2181. // Color InputText fields that will be updated upon value change
  2182. var picker;
  2183. var rValInt;
  2184. var gValInt;
  2185. var bValInt;
  2186. var rValDec;
  2187. var gValDec;
  2188. var bValDec;
  2189. var hexVal;
  2190. var newSwatch;
  2191. var lastVal;
  2192. var activeField;
  2193. /**
  2194. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2195. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2196. * are will receive no update. This is to prevent the input from the user being overwritten.
  2197. */
  2198. function updateValues(value, inputField) {
  2199. activeField = inputField;
  2200. var pickedColor = value.toHexString();
  2201. newSwatch.background = pickedColor;
  2202. if (rValInt.name != activeField) {
  2203. rValInt.text = Math.floor(value.r * 255).toString();
  2204. }
  2205. if (gValInt.name != activeField) {
  2206. gValInt.text = Math.floor(value.g * 255).toString();
  2207. }
  2208. if (bValInt.name != activeField) {
  2209. bValInt.text = Math.floor(value.b * 255).toString();
  2210. }
  2211. if (rValDec.name != activeField) {
  2212. rValDec.text = value.r.toString();
  2213. }
  2214. if (gValDec.name != activeField) {
  2215. gValDec.text = value.g.toString();
  2216. }
  2217. if (bValDec.name != activeField) {
  2218. bValDec.text = value.b.toString();
  2219. }
  2220. if (hexVal.name != activeField) {
  2221. var minusPound = pickedColor.split("#");
  2222. hexVal.text = minusPound[1];
  2223. }
  2224. if (picker.name != activeField) {
  2225. picker.value = value;
  2226. }
  2227. }
  2228. // When the user enters an integer for R, G, or B we check to make sure it is a valid number and replace if not.
  2229. function updateInt(field, channel) {
  2230. var newValue = field.text;
  2231. var checkVal = /[^0-9]/g.test(newValue);
  2232. if (checkVal) {
  2233. field.text = lastVal;
  2234. return;
  2235. }
  2236. else {
  2237. if (newValue != "") {
  2238. if (Math.floor(parseInt(newValue)) < 0) {
  2239. newValue = "0";
  2240. }
  2241. else if (Math.floor(parseInt(newValue)) > 255) {
  2242. newValue = "255";
  2243. }
  2244. else if (isNaN(parseInt(newValue))) {
  2245. newValue = "0";
  2246. }
  2247. }
  2248. if (activeField == field.name) {
  2249. lastVal = newValue;
  2250. }
  2251. }
  2252. if (newValue != "") {
  2253. newValue = parseInt(newValue).toString();
  2254. field.text = newValue;
  2255. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2256. if (activeField == field.name) {
  2257. if (channel == "r") {
  2258. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2259. }
  2260. else if (channel == "g") {
  2261. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2262. }
  2263. else {
  2264. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2265. }
  2266. }
  2267. }
  2268. }
  2269. // When the user enters a float for R, G, or B we check to make sure it is a valid number and replace if not.
  2270. function updateFloat(field, channel) {
  2271. var newValue = field.text;
  2272. var checkVal = /[^0-9\.]/g.test(newValue);
  2273. if (checkVal) {
  2274. field.text = lastVal;
  2275. return;
  2276. }
  2277. else {
  2278. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2279. if (parseFloat(newValue) < 0.0) {
  2280. newValue = "0.0";
  2281. }
  2282. else if (parseFloat(newValue) > 1.0) {
  2283. newValue = "1.0";
  2284. }
  2285. else if (isNaN(parseFloat(newValue))) {
  2286. newValue = "0.0";
  2287. }
  2288. }
  2289. if (activeField == field.name) {
  2290. lastVal = newValue;
  2291. }
  2292. }
  2293. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2294. newValue = parseFloat(newValue).toString();
  2295. field.text = newValue;
  2296. }
  2297. else {
  2298. newValue = "0.0";
  2299. }
  2300. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2301. if (activeField == field.name) {
  2302. if (channel == "r") {
  2303. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2304. }
  2305. else if (channel == "g") {
  2306. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2307. }
  2308. else {
  2309. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2310. }
  2311. }
  2312. }
  2313. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2314. function deleteSwatch(index) {
  2315. if (options.savedColors) {
  2316. options.savedColors.splice(index, 1);
  2317. }
  2318. if (options.savedColors && options.savedColors.length == 0) {
  2319. setEditButtonVisibility(false);
  2320. editSwatchMode = false;
  2321. }
  2322. }
  2323. // Creates and styles an individual swatch when updateSwatches is called.
  2324. function createSwatch() {
  2325. if (options.savedColors && options.savedColors[swatchNumber]) {
  2326. if (editSwatchMode) {
  2327. var icon = "b";
  2328. }
  2329. else {
  2330. var icon = "";
  2331. }
  2332. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2333. swatch.fontFamily = "BabylonJSglyphs";
  2334. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2335. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2336. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2337. if (swatchLuminence > luminanceLimit) {
  2338. swatch.color = iconColorDark;
  2339. }
  2340. else {
  2341. swatch.color = iconColorLight;
  2342. }
  2343. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2344. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2345. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2346. swatch.background = options.savedColors[swatchNumber];
  2347. swatch.thickness = 2;
  2348. var metadata_1 = swatchNumber;
  2349. swatch.pointerDownAnimation = function () {
  2350. swatch.thickness = 4;
  2351. };
  2352. swatch.pointerUpAnimation = function () {
  2353. swatch.thickness = 3;
  2354. };
  2355. swatch.pointerEnterAnimation = function () {
  2356. swatch.thickness = 3;
  2357. };
  2358. swatch.pointerOutAnimation = function () {
  2359. swatch.thickness = 2;
  2360. };
  2361. swatch.onPointerClickObservable.add(function () {
  2362. if (!editSwatchMode) {
  2363. if (options.savedColors) {
  2364. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2365. }
  2366. }
  2367. else {
  2368. deleteSwatch(metadata_1);
  2369. updateSwatches("", butSave);
  2370. }
  2371. });
  2372. return swatch;
  2373. }
  2374. else {
  2375. return null;
  2376. }
  2377. }
  2378. // Mode switch to render button text and close symbols on swatch controls
  2379. function editSwatches(mode) {
  2380. if (mode !== undefined) {
  2381. editSwatchMode = mode;
  2382. }
  2383. if (editSwatchMode) {
  2384. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2385. var thisButton = swatchDrawer.children[i];
  2386. thisButton.textBlock.text = "b";
  2387. }
  2388. if (butEdit !== undefined) {
  2389. butEdit.textBlock.text = "Done";
  2390. }
  2391. }
  2392. else {
  2393. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2394. var thisButton = swatchDrawer.children[i];
  2395. thisButton.textBlock.text = "";
  2396. }
  2397. if (butEdit !== undefined) {
  2398. butEdit.textBlock.text = "Edit";
  2399. }
  2400. }
  2401. }
  2402. /**
  2403. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2404. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2405. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2406. * saved colors there are and how many can be stored per row.
  2407. */
  2408. function updateSwatches(color, button) {
  2409. if (options.savedColors) {
  2410. if (color != "") {
  2411. options.savedColors.push(color);
  2412. }
  2413. swatchNumber = 0;
  2414. swatchDrawer.clearControls();
  2415. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2416. if (rowCount == 0) {
  2417. var gutterCount = 0;
  2418. }
  2419. else {
  2420. var gutterCount = rowCount + 1;
  2421. }
  2422. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2423. var currentRows = swatchDrawer.rowCount;
  2424. for (var i = 0; i < currentRows; i++) {
  2425. swatchDrawer.removeRowDefinition(0);
  2426. }
  2427. for (var i = 0; i < rowCount + gutterCount; i++) {
  2428. if (i % 2) {
  2429. swatchDrawer.addRowDefinition(swatchSize, true);
  2430. }
  2431. else {
  2432. swatchDrawer.addRowDefinition(gutterSize, true);
  2433. }
  2434. }
  2435. }
  2436. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2437. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2438. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2439. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2440. var totalButtonsThisRow = options.numSwatchesPerLine;
  2441. }
  2442. else {
  2443. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2444. }
  2445. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2446. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2447. if (x > options.numSwatchesPerLine) {
  2448. continue;
  2449. }
  2450. var swatch = createSwatch();
  2451. if (swatch != null) {
  2452. swatchDrawer.addControl(swatch, y, w);
  2453. w += 2;
  2454. swatchNumber++;
  2455. }
  2456. else {
  2457. continue;
  2458. }
  2459. }
  2460. }
  2461. if (options.savedColors.length >= options.swatchLimit) {
  2462. disableButton(button, true);
  2463. }
  2464. else {
  2465. disableButton(button, false);
  2466. }
  2467. }
  2468. }
  2469. // Shows or hides edit swatches button depending on if there are saved swatches
  2470. function setEditButtonVisibility(enableButton) {
  2471. if (enableButton) {
  2472. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2473. butEdit.width = buttonWidth;
  2474. butEdit.height = buttonHeight;
  2475. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2476. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2477. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2478. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2479. butEdit.thickness = 2;
  2480. butEdit.color = buttonColor;
  2481. butEdit.fontSize = buttonFontSize;
  2482. butEdit.background = buttonBackgroundColor;
  2483. butEdit.onPointerEnterObservable.add(function () {
  2484. butEdit.background = buttonBackgroundHoverColor;
  2485. });
  2486. butEdit.onPointerOutObservable.add(function () {
  2487. butEdit.background = buttonBackgroundColor;
  2488. });
  2489. butEdit.pointerDownAnimation = function () {
  2490. butEdit.background = buttonBackgroundClickColor;
  2491. };
  2492. butEdit.pointerUpAnimation = function () {
  2493. butEdit.background = buttonBackgroundHoverColor;
  2494. };
  2495. butEdit.onPointerClickObservable.add(function () {
  2496. if (editSwatchMode) {
  2497. editSwatchMode = false;
  2498. }
  2499. else {
  2500. editSwatchMode = true;
  2501. }
  2502. editSwatches();
  2503. });
  2504. pickerGrid.addControl(butEdit, 1, 0);
  2505. }
  2506. else {
  2507. pickerGrid.removeControl(butEdit);
  2508. }
  2509. }
  2510. // Called when the user hits the limit of saved colors in the drawer.
  2511. function disableButton(button, disabled) {
  2512. if (disabled) {
  2513. button.color = buttonDisabledColor;
  2514. button.background = buttonDisabledBackgroundColor;
  2515. }
  2516. else {
  2517. button.color = buttonColor;
  2518. button.background = buttonBackgroundColor;
  2519. }
  2520. }
  2521. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2522. function closePicker(color) {
  2523. if (options.savedColors && options.savedColors.length > 0) {
  2524. resolve({
  2525. savedColors: options.savedColors,
  2526. pickedColor: color
  2527. });
  2528. }
  2529. else {
  2530. resolve({
  2531. pickedColor: color
  2532. });
  2533. }
  2534. advancedTexture.removeControl(dialogContainer);
  2535. }
  2536. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2537. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2538. dialogContainer.name = "Dialog Container";
  2539. dialogContainer.width = options.pickerWidth;
  2540. if (options.savedColors) {
  2541. dialogContainer.height = containerSize;
  2542. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2543. dialogContainer.addRowDefinition(topRow, false);
  2544. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2545. }
  2546. else {
  2547. dialogContainer.height = options.pickerHeight;
  2548. dialogContainer.addRowDefinition(1.0, false);
  2549. }
  2550. advancedTexture.addControl(dialogContainer);
  2551. // Swatch drawer which contains all saved color buttons
  2552. if (options.savedColors) {
  2553. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2554. swatchDrawer.name = "Swatch Drawer";
  2555. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2556. swatchDrawer.background = buttonBackgroundColor;
  2557. swatchDrawer.width = options.pickerWidth;
  2558. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2559. if (initialRows == 0) {
  2560. var gutterCount = 0;
  2561. }
  2562. else {
  2563. var gutterCount = initialRows + 1;
  2564. }
  2565. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2566. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2567. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2568. if (i % 2 != 0) {
  2569. swatchDrawer.addRowDefinition(swatchSize, true);
  2570. }
  2571. else {
  2572. swatchDrawer.addRowDefinition(gutterSize, true);
  2573. }
  2574. }
  2575. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2576. if (i % 2 != 0) {
  2577. swatchDrawer.addColumnDefinition(swatchSize, true);
  2578. }
  2579. else {
  2580. swatchDrawer.addColumnDefinition(gutterSize, true);
  2581. }
  2582. }
  2583. dialogContainer.addControl(swatchDrawer, 1, 0);
  2584. }
  2585. // Picker container
  2586. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2587. pickerPanel.name = "Picker Panel";
  2588. pickerPanel.height = options.pickerHeight;
  2589. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2590. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2591. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2592. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2593. dialogContainer.addControl(pickerPanel, 0, 0);
  2594. // Picker container header
  2595. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2596. header.name = "Dialogue Header Bar";
  2597. header.background = "#cccccc";
  2598. header.thickness = 0;
  2599. pickerPanel.addControl(header, 0, 0);
  2600. // Header close button
  2601. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2602. closeButton.fontFamily = "BabylonJSglyphs";
  2603. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2604. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2605. closeButton.color = closeIconColor.toHexString();
  2606. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2607. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2608. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2609. closeButton.height = closeButton.width = options.headerHeight;
  2610. closeButton.background = header.background;
  2611. closeButton.thickness = 0;
  2612. closeButton.pointerDownAnimation = function () {
  2613. };
  2614. closeButton.pointerUpAnimation = function () {
  2615. closeButton.background = header.background;
  2616. };
  2617. closeButton.pointerEnterAnimation = function () {
  2618. closeButton.color = header.background;
  2619. closeButton.background = "red";
  2620. };
  2621. closeButton.pointerOutAnimation = function () {
  2622. closeButton.color = closeIconColor.toHexString();
  2623. closeButton.background = header.background;
  2624. };
  2625. closeButton.onPointerClickObservable.add(function () {
  2626. closePicker(currentSwatch.background);
  2627. });
  2628. pickerPanel.addControl(closeButton, 0, 0);
  2629. // Dialog container body
  2630. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2631. dialogBody.name = "Dialogue Body";
  2632. dialogBody.background = buttonBackgroundColor;
  2633. var dialogBodyCols = [0.4375, 0.5625];
  2634. dialogBody.addRowDefinition(1.0, false);
  2635. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2636. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2637. pickerPanel.addControl(dialogBody, 1, 0);
  2638. // Picker grid
  2639. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2640. pickerGrid.name = "Picker Grid";
  2641. pickerGrid.addRowDefinition(0.85, false);
  2642. pickerGrid.addRowDefinition(0.15, false);
  2643. dialogBody.addControl(pickerGrid, 0, 0);
  2644. // Picker control
  2645. picker = new ColorPicker();
  2646. picker.name = "GUI Color Picker";
  2647. if (options.pickerHeight < options.pickerWidth) {
  2648. picker.width = 0.89;
  2649. }
  2650. else {
  2651. picker.height = 0.89;
  2652. }
  2653. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2654. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2655. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2656. picker.onPointerDownObservable.add(function () {
  2657. activeField = picker.name;
  2658. lastVal = "";
  2659. editSwatches(false);
  2660. });
  2661. picker.onValueChangedObservable.add(function (value) {
  2662. if (activeField == picker.name) {
  2663. updateValues(value, picker.name);
  2664. }
  2665. });
  2666. pickerGrid.addControl(picker, 0, 0);
  2667. // Picker body right quarant
  2668. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2669. pickerBodyRight.name = "Dialogue Right Half";
  2670. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2671. var pickerBodyRightRows = [0.514, 0.486];
  2672. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2673. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2674. dialogBody.addControl(pickerBodyRight, 1, 1);
  2675. // Picker container swatches and buttons
  2676. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2677. pickerSwatchesButtons.name = "Swatches and Buttons";
  2678. var pickerButtonsCol = [0.417, 0.583];
  2679. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2680. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2681. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2682. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2683. // Picker Swatches quadrant
  2684. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2685. pickerSwatches.name = "New and Current Swatches";
  2686. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2687. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2688. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2689. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2690. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2691. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2692. // Active swatches
  2693. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2694. activeSwatches.name = "Active Swatches";
  2695. activeSwatches.width = 0.67;
  2696. activeSwatches.addRowDefinition(0.5, false);
  2697. activeSwatches.addRowDefinition(0.5, false);
  2698. pickerSwatches.addControl(activeSwatches, 2, 0);
  2699. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2700. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2701. if (options.pickerWidth > options.pickerHeight) {
  2702. var labelTextSize = labelHeight;
  2703. }
  2704. else {
  2705. var labelTextSize = labelWidth;
  2706. }
  2707. // New color swatch and previous color button
  2708. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2709. newText.text = "new";
  2710. newText.name = "New Color Label";
  2711. newText.color = buttonColor;
  2712. newText.fontSize = labelTextSize;
  2713. pickerSwatches.addControl(newText, 1, 0);
  2714. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2715. newSwatch.name = "New Color Swatch";
  2716. newSwatch.background = options.lastColor;
  2717. newSwatch.thickness = 0;
  2718. activeSwatches.addControl(newSwatch, 0, 0);
  2719. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2720. currentSwatch.background = options.lastColor;
  2721. currentSwatch.thickness = 0;
  2722. currentSwatch.onPointerClickObservable.add(function () {
  2723. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2724. updateValues(revertColor, currentSwatch.name);
  2725. editSwatches(false);
  2726. });
  2727. currentSwatch.pointerDownAnimation = function () { };
  2728. currentSwatch.pointerUpAnimation = function () { };
  2729. currentSwatch.pointerEnterAnimation = function () { };
  2730. currentSwatch.pointerOutAnimation = function () { };
  2731. activeSwatches.addControl(currentSwatch, 1, 0);
  2732. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2733. swatchOutline.name = "Swatch Outline";
  2734. swatchOutline.width = 0.67;
  2735. swatchOutline.thickness = 2;
  2736. swatchOutline.color = currentSwatchesOutlineColor;
  2737. swatchOutline.isHitTestVisible = false;
  2738. pickerSwatches.addControl(swatchOutline, 2, 0);
  2739. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2740. currentText.name = "Current Color Label";
  2741. currentText.text = "current";
  2742. currentText.color = buttonColor;
  2743. currentText.fontSize = labelTextSize;
  2744. pickerSwatches.addControl(currentText, 3, 0);
  2745. // Buttons grid
  2746. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2747. buttonGrid.name = "Button Grid";
  2748. buttonGrid.height = 0.8;
  2749. var buttonGridRows = 1 / 3;
  2750. buttonGrid.addRowDefinition(buttonGridRows, false);
  2751. buttonGrid.addRowDefinition(buttonGridRows, false);
  2752. buttonGrid.addRowDefinition(buttonGridRows, false);
  2753. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2754. // Determine pixel width and height for all buttons from overall panel dimensions
  2755. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2756. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2757. // Determine button type size
  2758. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2759. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2760. }
  2761. else {
  2762. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2763. }
  2764. // Panel Buttons
  2765. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2766. butOK.width = buttonWidth;
  2767. butOK.height = buttonHeight;
  2768. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2769. butOK.thickness = 2;
  2770. butOK.color = buttonColor;
  2771. butOK.fontSize = buttonFontSize;
  2772. butOK.background = buttonBackgroundColor;
  2773. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2774. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2775. butOK.pointerDownAnimation = function () {
  2776. butOK.background = buttonBackgroundClickColor;
  2777. };
  2778. butOK.pointerUpAnimation = function () {
  2779. butOK.background = buttonBackgroundHoverColor;
  2780. };
  2781. butOK.onPointerClickObservable.add(function () {
  2782. editSwatches(false);
  2783. closePicker(newSwatch.background);
  2784. });
  2785. buttonGrid.addControl(butOK, 0, 0);
  2786. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2787. butCancel.width = buttonWidth;
  2788. butCancel.height = buttonHeight;
  2789. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2790. butCancel.thickness = 2;
  2791. butCancel.color = buttonColor;
  2792. butCancel.fontSize = buttonFontSize;
  2793. butCancel.background = buttonBackgroundColor;
  2794. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2795. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2796. butCancel.pointerDownAnimation = function () {
  2797. butCancel.background = buttonBackgroundClickColor;
  2798. };
  2799. butCancel.pointerUpAnimation = function () {
  2800. butCancel.background = buttonBackgroundHoverColor;
  2801. };
  2802. butCancel.onPointerClickObservable.add(function () {
  2803. editSwatches(false);
  2804. closePicker(currentSwatch.background);
  2805. });
  2806. buttonGrid.addControl(butCancel, 1, 0);
  2807. if (options.savedColors) {
  2808. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2809. butSave.width = buttonWidth;
  2810. butSave.height = buttonHeight;
  2811. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2812. butSave.thickness = 2;
  2813. butSave.fontSize = buttonFontSize;
  2814. if (options.savedColors.length < options.swatchLimit) {
  2815. butSave.color = buttonColor;
  2816. butSave.background = buttonBackgroundColor;
  2817. }
  2818. else {
  2819. disableButton(butSave, true);
  2820. }
  2821. butSave.onPointerEnterObservable.add(function () {
  2822. if (options.savedColors) {
  2823. if (options.savedColors.length < options.swatchLimit) {
  2824. butSave.background = buttonBackgroundHoverColor;
  2825. }
  2826. }
  2827. });
  2828. butSave.onPointerOutObservable.add(function () {
  2829. if (options.savedColors) {
  2830. if (options.savedColors.length < options.swatchLimit) {
  2831. butSave.background = buttonBackgroundColor;
  2832. }
  2833. }
  2834. });
  2835. butSave.pointerDownAnimation = function () {
  2836. if (options.savedColors) {
  2837. if (options.savedColors.length < options.swatchLimit) {
  2838. butSave.background = buttonBackgroundClickColor;
  2839. }
  2840. }
  2841. };
  2842. butSave.pointerUpAnimation = function () {
  2843. if (options.savedColors) {
  2844. if (options.savedColors.length < options.swatchLimit) {
  2845. butSave.background = buttonBackgroundHoverColor;
  2846. }
  2847. }
  2848. };
  2849. butSave.onPointerClickObservable.add(function () {
  2850. if (options.savedColors) {
  2851. if (options.savedColors.length == 0) {
  2852. setEditButtonVisibility(true);
  2853. }
  2854. if (options.savedColors.length < options.swatchLimit) {
  2855. updateSwatches(newSwatch.background, butSave);
  2856. }
  2857. editSwatches(false);
  2858. }
  2859. });
  2860. if (options.savedColors.length > 0) {
  2861. setEditButtonVisibility(true);
  2862. }
  2863. buttonGrid.addControl(butSave, 2, 0);
  2864. }
  2865. // Picker color values input
  2866. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2867. pickerColorValues.name = "Dialog Lower Right";
  2868. pickerColorValues.addRowDefinition(0.02, false);
  2869. pickerColorValues.addRowDefinition(0.63, false);
  2870. pickerColorValues.addRowDefinition(0.21, false);
  2871. pickerColorValues.addRowDefinition(0.14, false);
  2872. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2873. // RGB values text boxes
  2874. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2875. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2876. rgbValuesQuadrant.name = "RGB Values";
  2877. rgbValuesQuadrant.width = 0.82;
  2878. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2879. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2880. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2881. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2882. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2883. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2884. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2885. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2886. for (var i = 0; i < inputFieldLabels.length; i++) {
  2887. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2888. labelText.text = inputFieldLabels[i];
  2889. labelText.color = buttonColor;
  2890. labelText.fontSize = buttonFontSize;
  2891. rgbValuesQuadrant.addControl(labelText, i, 0);
  2892. }
  2893. // Input fields for RGB values
  2894. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2895. rValInt.width = 0.83;
  2896. rValInt.height = 0.72;
  2897. rValInt.name = "rIntField";
  2898. rValInt.fontSize = buttonFontSize;
  2899. rValInt.text = (currentColor.r * 255).toString();
  2900. rValInt.color = inputTextColor;
  2901. rValInt.background = inputTextBackgroundColor;
  2902. rValInt.onFocusObservable.add(function () {
  2903. activeField = rValInt.name;
  2904. lastVal = rValInt.text;
  2905. editSwatches(false);
  2906. });
  2907. rValInt.onBlurObservable.add(function () {
  2908. if (rValInt.text == "") {
  2909. rValInt.text = "0";
  2910. }
  2911. updateInt(rValInt, "r");
  2912. if (activeField == rValInt.name) {
  2913. activeField = "";
  2914. }
  2915. });
  2916. rValInt.onTextChangedObservable.add(function () {
  2917. if (activeField == rValInt.name) {
  2918. updateInt(rValInt, "r");
  2919. }
  2920. });
  2921. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2922. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2923. gValInt.width = 0.83;
  2924. gValInt.height = 0.72;
  2925. gValInt.name = "gIntField";
  2926. gValInt.fontSize = buttonFontSize;
  2927. gValInt.text = (currentColor.g * 255).toString();
  2928. gValInt.color = inputTextColor;
  2929. gValInt.background = inputTextBackgroundColor;
  2930. gValInt.onFocusObservable.add(function () {
  2931. activeField = gValInt.name;
  2932. lastVal = gValInt.text;
  2933. editSwatches(false);
  2934. });
  2935. gValInt.onBlurObservable.add(function () {
  2936. if (gValInt.text == "") {
  2937. gValInt.text = "0";
  2938. }
  2939. updateInt(gValInt, "g");
  2940. if (activeField == gValInt.name) {
  2941. activeField = "";
  2942. }
  2943. });
  2944. gValInt.onTextChangedObservable.add(function () {
  2945. if (activeField == gValInt.name) {
  2946. updateInt(gValInt, "g");
  2947. }
  2948. });
  2949. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2950. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2951. bValInt.width = 0.83;
  2952. bValInt.height = 0.72;
  2953. bValInt.name = "bIntField";
  2954. bValInt.fontSize = buttonFontSize;
  2955. bValInt.text = (currentColor.b * 255).toString();
  2956. bValInt.color = inputTextColor;
  2957. bValInt.background = inputTextBackgroundColor;
  2958. bValInt.onFocusObservable.add(function () {
  2959. activeField = bValInt.name;
  2960. lastVal = bValInt.text;
  2961. editSwatches(false);
  2962. });
  2963. bValInt.onBlurObservable.add(function () {
  2964. if (bValInt.text == "") {
  2965. bValInt.text = "0";
  2966. }
  2967. updateInt(bValInt, "b");
  2968. if (activeField == bValInt.name) {
  2969. activeField = "";
  2970. }
  2971. });
  2972. bValInt.onTextChangedObservable.add(function () {
  2973. if (activeField == bValInt.name) {
  2974. updateInt(bValInt, "b");
  2975. }
  2976. });
  2977. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2978. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2979. rValDec.width = 0.95;
  2980. rValDec.height = 0.72;
  2981. rValDec.name = "rDecField";
  2982. rValDec.fontSize = buttonFontSize;
  2983. rValDec.text = currentColor.r.toString();
  2984. rValDec.color = inputTextColor;
  2985. rValDec.background = inputTextBackgroundColor;
  2986. rValDec.onFocusObservable.add(function () {
  2987. activeField = rValDec.name;
  2988. lastVal = rValDec.text;
  2989. editSwatches(false);
  2990. });
  2991. rValDec.onBlurObservable.add(function () {
  2992. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2993. rValDec.text = "0";
  2994. updateFloat(rValDec, "r");
  2995. }
  2996. if (activeField == rValDec.name) {
  2997. activeField = "";
  2998. }
  2999. });
  3000. rValDec.onTextChangedObservable.add(function () {
  3001. if (activeField == rValDec.name) {
  3002. updateFloat(rValDec, "r");
  3003. }
  3004. });
  3005. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3006. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3007. gValDec.width = 0.95;
  3008. gValDec.height = 0.72;
  3009. gValDec.name = "gDecField";
  3010. gValDec.fontSize = buttonFontSize;
  3011. gValDec.text = currentColor.g.toString();
  3012. gValDec.color = inputTextColor;
  3013. gValDec.background = inputTextBackgroundColor;
  3014. gValDec.onFocusObservable.add(function () {
  3015. activeField = gValDec.name;
  3016. lastVal = gValDec.text;
  3017. editSwatches(false);
  3018. });
  3019. gValDec.onBlurObservable.add(function () {
  3020. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3021. gValDec.text = "0";
  3022. updateFloat(gValDec, "g");
  3023. }
  3024. if (activeField == gValDec.name) {
  3025. activeField = "";
  3026. }
  3027. });
  3028. gValDec.onTextChangedObservable.add(function () {
  3029. if (activeField == gValDec.name) {
  3030. updateFloat(gValDec, "g");
  3031. }
  3032. });
  3033. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3034. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3035. bValDec.width = 0.95;
  3036. bValDec.height = 0.72;
  3037. bValDec.name = "bDecField";
  3038. bValDec.fontSize = buttonFontSize;
  3039. bValDec.text = currentColor.b.toString();
  3040. bValDec.color = inputTextColor;
  3041. bValDec.background = inputTextBackgroundColor;
  3042. bValDec.onFocusObservable.add(function () {
  3043. activeField = bValDec.name;
  3044. lastVal = bValDec.text;
  3045. editSwatches(false);
  3046. });
  3047. bValDec.onBlurObservable.add(function () {
  3048. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3049. bValDec.text = "0";
  3050. updateFloat(bValDec, "b");
  3051. }
  3052. if (activeField == bValDec.name) {
  3053. activeField = "";
  3054. }
  3055. });
  3056. bValDec.onTextChangedObservable.add(function () {
  3057. if (activeField == bValDec.name) {
  3058. updateFloat(bValDec, "b");
  3059. }
  3060. });
  3061. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3062. // Hex value input
  3063. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3064. hexValueQuadrant.name = "Hex Value";
  3065. hexValueQuadrant.width = 0.82;
  3066. hexValueQuadrant.addRowDefinition(1.0, false);
  3067. hexValueQuadrant.addColumnDefinition(0.1, false);
  3068. hexValueQuadrant.addColumnDefinition(0.9, false);
  3069. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3070. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3071. labelText.text = "#";
  3072. labelText.color = buttonColor;
  3073. labelText.fontSize = buttonFontSize;
  3074. hexValueQuadrant.addControl(labelText, 0, 0);
  3075. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3076. hexVal.width = 0.96;
  3077. hexVal.height = 0.72;
  3078. hexVal.name = "hexField";
  3079. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3080. hexVal.fontSize = buttonFontSize;
  3081. var minusPound = options.lastColor.split("#");
  3082. hexVal.text = minusPound[1];
  3083. hexVal.color = inputTextColor;
  3084. hexVal.background = inputTextBackgroundColor;
  3085. hexVal.onFocusObservable.add(function () {
  3086. activeField = hexVal.name;
  3087. lastVal = hexVal.text;
  3088. editSwatches(false);
  3089. });
  3090. hexVal.onBlurObservable.add(function () {
  3091. if (hexVal.text.length == 3) {
  3092. var val = hexVal.text.split("");
  3093. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3094. }
  3095. if (hexVal.text == "") {
  3096. hexVal.text = "000000";
  3097. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3098. }
  3099. if (activeField == hexVal.name) {
  3100. activeField = "";
  3101. }
  3102. });
  3103. hexVal.onTextChangedObservable.add(function () {
  3104. var newHexValue = hexVal.text;
  3105. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3106. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3107. hexVal.text = lastVal;
  3108. }
  3109. else {
  3110. if (hexVal.text.length < 6) {
  3111. var leadingZero = 6 - hexVal.text.length;
  3112. for (var i = 0; i < leadingZero; i++) {
  3113. newHexValue = "0" + newHexValue;
  3114. }
  3115. }
  3116. if (hexVal.text.length == 3) {
  3117. var val = hexVal.text.split("");
  3118. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3119. }
  3120. newHexValue = "#" + newHexValue;
  3121. if (activeField == hexVal.name) {
  3122. lastVal = hexVal.text;
  3123. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3124. }
  3125. }
  3126. });
  3127. hexValueQuadrant.addControl(hexVal, 0, 1);
  3128. if (options.savedColors && options.savedColors.length > 0) {
  3129. updateSwatches("", butSave);
  3130. }
  3131. });
  3132. };
  3133. ColorPicker._Epsilon = 0.000001;
  3134. return ColorPicker;
  3135. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3136. /***/ }),
  3137. /***/ "./2D/controls/container.ts":
  3138. /*!**********************************!*\
  3139. !*** ./2D/controls/container.ts ***!
  3140. \**********************************/
  3141. /*! exports provided: Container */
  3142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3143. "use strict";
  3144. __webpack_require__.r(__webpack_exports__);
  3145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3146. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3147. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable");
  3148. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3149. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3150. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3151. /**
  3152. * Root class for 2D containers
  3153. * @see http://doc.babylonjs.com/how_to/gui#containers
  3154. */
  3155. var Container = /** @class */ (function (_super) {
  3156. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3157. /**
  3158. * Creates a new Container
  3159. * @param name defines the name of the container
  3160. */
  3161. function Container(name) {
  3162. var _this = _super.call(this, name) || this;
  3163. _this.name = name;
  3164. /** @hidden */
  3165. _this._children = new Array();
  3166. /** @hidden */
  3167. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3168. /** @hidden */
  3169. _this._background = "";
  3170. /** @hidden */
  3171. _this._adaptWidthToChildren = false;
  3172. /** @hidden */
  3173. _this._adaptHeightToChildren = false;
  3174. return _this;
  3175. }
  3176. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3177. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3178. get: function () {
  3179. return this._adaptHeightToChildren;
  3180. },
  3181. set: function (value) {
  3182. if (this._adaptHeightToChildren === value) {
  3183. return;
  3184. }
  3185. this._adaptHeightToChildren = value;
  3186. if (value) {
  3187. this.height = "100%";
  3188. }
  3189. this._markAsDirty();
  3190. },
  3191. enumerable: true,
  3192. configurable: true
  3193. });
  3194. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3195. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3196. get: function () {
  3197. return this._adaptWidthToChildren;
  3198. },
  3199. set: function (value) {
  3200. if (this._adaptWidthToChildren === value) {
  3201. return;
  3202. }
  3203. this._adaptWidthToChildren = value;
  3204. if (value) {
  3205. this.width = "100%";
  3206. }
  3207. this._markAsDirty();
  3208. },
  3209. enumerable: true,
  3210. configurable: true
  3211. });
  3212. Object.defineProperty(Container.prototype, "background", {
  3213. /** Gets or sets background color */
  3214. get: function () {
  3215. return this._background;
  3216. },
  3217. set: function (value) {
  3218. if (this._background === value) {
  3219. return;
  3220. }
  3221. this._background = value;
  3222. this._markAsDirty();
  3223. },
  3224. enumerable: true,
  3225. configurable: true
  3226. });
  3227. Object.defineProperty(Container.prototype, "children", {
  3228. /** Gets the list of children */
  3229. get: function () {
  3230. return this._children;
  3231. },
  3232. enumerable: true,
  3233. configurable: true
  3234. });
  3235. Container.prototype._getTypeName = function () {
  3236. return "Container";
  3237. };
  3238. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3239. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3240. var child = _a[_i];
  3241. child._markMatrixAsDirty();
  3242. }
  3243. };
  3244. /**
  3245. * Gets a child using its name
  3246. * @param name defines the child name to look for
  3247. * @returns the child control if found
  3248. */
  3249. Container.prototype.getChildByName = function (name) {
  3250. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3251. var child = _a[_i];
  3252. if (child.name === name) {
  3253. return child;
  3254. }
  3255. }
  3256. return null;
  3257. };
  3258. /**
  3259. * Gets a child using its type and its name
  3260. * @param name defines the child name to look for
  3261. * @param type defines the child type to look for
  3262. * @returns the child control if found
  3263. */
  3264. Container.prototype.getChildByType = function (name, type) {
  3265. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3266. var child = _a[_i];
  3267. if (child.typeName === type) {
  3268. return child;
  3269. }
  3270. }
  3271. return null;
  3272. };
  3273. /**
  3274. * Search for a specific control in children
  3275. * @param control defines the control to look for
  3276. * @returns true if the control is in child list
  3277. */
  3278. Container.prototype.containsControl = function (control) {
  3279. return this.children.indexOf(control) !== -1;
  3280. };
  3281. /**
  3282. * Adds a new control to the current container
  3283. * @param control defines the control to add
  3284. * @returns the current container
  3285. */
  3286. Container.prototype.addControl = function (control) {
  3287. if (!control) {
  3288. return this;
  3289. }
  3290. var index = this._children.indexOf(control);
  3291. if (index !== -1) {
  3292. return this;
  3293. }
  3294. control._link(this._host);
  3295. control._markAllAsDirty();
  3296. this._reOrderControl(control);
  3297. this._markAsDirty();
  3298. return this;
  3299. };
  3300. /**
  3301. * Removes all controls from the current container
  3302. * @returns the current container
  3303. */
  3304. Container.prototype.clearControls = function () {
  3305. var children = this.children.slice();
  3306. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3307. var child = children_1[_i];
  3308. this.removeControl(child);
  3309. }
  3310. return this;
  3311. };
  3312. /**
  3313. * Removes a control from the current container
  3314. * @param control defines the control to remove
  3315. * @returns the current container
  3316. */
  3317. Container.prototype.removeControl = function (control) {
  3318. var index = this._children.indexOf(control);
  3319. if (index !== -1) {
  3320. this._children.splice(index, 1);
  3321. control.parent = null;
  3322. }
  3323. control.linkWithMesh(null);
  3324. if (this._host) {
  3325. this._host._cleanControlAfterRemoval(control);
  3326. }
  3327. this._markAsDirty();
  3328. return this;
  3329. };
  3330. /** @hidden */
  3331. Container.prototype._reOrderControl = function (control) {
  3332. this.removeControl(control);
  3333. var wasAdded = false;
  3334. for (var index = 0; index < this._children.length; index++) {
  3335. if (this._children[index].zIndex > control.zIndex) {
  3336. this._children.splice(index, 0, control);
  3337. wasAdded = true;
  3338. break;
  3339. }
  3340. }
  3341. if (!wasAdded) {
  3342. this._children.push(control);
  3343. }
  3344. control.parent = this;
  3345. this._markAsDirty();
  3346. };
  3347. /** @hidden */
  3348. Container.prototype._offsetLeft = function (offset) {
  3349. _super.prototype._offsetLeft.call(this, offset);
  3350. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3351. var child = _a[_i];
  3352. child._offsetLeft(offset);
  3353. }
  3354. };
  3355. /** @hidden */
  3356. Container.prototype._offsetTop = function (offset) {
  3357. _super.prototype._offsetTop.call(this, offset);
  3358. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3359. var child = _a[_i];
  3360. child._offsetTop(offset);
  3361. }
  3362. };
  3363. /** @hidden */
  3364. Container.prototype._markAllAsDirty = function () {
  3365. _super.prototype._markAllAsDirty.call(this);
  3366. for (var index = 0; index < this._children.length; index++) {
  3367. this._children[index]._markAllAsDirty();
  3368. }
  3369. };
  3370. /** @hidden */
  3371. Container.prototype._localDraw = function (context) {
  3372. if (this._background) {
  3373. context.save();
  3374. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3375. context.shadowColor = this.shadowColor;
  3376. context.shadowBlur = this.shadowBlur;
  3377. context.shadowOffsetX = this.shadowOffsetX;
  3378. context.shadowOffsetY = this.shadowOffsetY;
  3379. }
  3380. context.fillStyle = this._background;
  3381. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3382. context.restore();
  3383. }
  3384. };
  3385. /** @hidden */
  3386. Container.prototype._link = function (host) {
  3387. _super.prototype._link.call(this, host);
  3388. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3389. var child = _a[_i];
  3390. child._link(host);
  3391. }
  3392. };
  3393. /** @hidden */
  3394. Container.prototype._beforeLayout = function () {
  3395. // Do nothing
  3396. };
  3397. /** @hidden */
  3398. Container.prototype._processMeasures = function (parentMeasure, context) {
  3399. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3400. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3401. this._evaluateClippingState(parentMeasure);
  3402. }
  3403. };
  3404. /** @hidden */
  3405. Container.prototype._layout = function (parentMeasure, context) {
  3406. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3407. return false;
  3408. }
  3409. if (this._isDirty) {
  3410. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3411. }
  3412. var rebuildCount = 0;
  3413. context.save();
  3414. this._applyStates(context);
  3415. this._beforeLayout();
  3416. do {
  3417. var computedWidth = -1;
  3418. var computedHeight = -1;
  3419. this._rebuildLayout = false;
  3420. this._processMeasures(parentMeasure, context);
  3421. if (!this._isClipped) {
  3422. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3423. var child = _a[_i];
  3424. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3425. if (child._layout(this._measureForChildren, context)) {
  3426. if (this.adaptWidthToChildren && child._width.isPixel) {
  3427. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3428. }
  3429. if (this.adaptHeightToChildren && child._height.isPixel) {
  3430. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3431. }
  3432. }
  3433. }
  3434. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3435. if (this.width !== computedWidth + "px") {
  3436. this.width = computedWidth + "px";
  3437. this._rebuildLayout = true;
  3438. }
  3439. }
  3440. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3441. if (this.height !== computedHeight + "px") {
  3442. this.height = computedHeight + "px";
  3443. this._rebuildLayout = true;
  3444. }
  3445. }
  3446. this._postMeasure();
  3447. }
  3448. rebuildCount++;
  3449. } while (this._rebuildLayout && rebuildCount < 3);
  3450. if (rebuildCount >= 3) {
  3451. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3452. }
  3453. context.restore();
  3454. if (this._isDirty) {
  3455. this.invalidateRect();
  3456. this._isDirty = false;
  3457. }
  3458. return true;
  3459. };
  3460. Container.prototype._postMeasure = function () {
  3461. // Do nothing by default
  3462. };
  3463. /** @hidden */
  3464. Container.prototype._draw = function (context, invalidatedRectangle) {
  3465. this._localDraw(context);
  3466. if (this.clipChildren) {
  3467. this._clipForChildren(context);
  3468. }
  3469. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3470. var child = _a[_i];
  3471. // Only redraw parts of the screen that are invalidated
  3472. if (invalidatedRectangle) {
  3473. if (!child._intersectsRect(invalidatedRectangle)) {
  3474. continue;
  3475. }
  3476. }
  3477. child._render(context, invalidatedRectangle);
  3478. }
  3479. };
  3480. /** @hidden */
  3481. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3482. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3483. if (!this.children) {
  3484. return;
  3485. }
  3486. for (var index = 0; index < this.children.length; index++) {
  3487. var item = this.children[index];
  3488. if (!predicate || predicate(item)) {
  3489. results.push(item);
  3490. }
  3491. if (!directDescendantsOnly) {
  3492. item._getDescendants(results, false, predicate);
  3493. }
  3494. }
  3495. };
  3496. /** @hidden */
  3497. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3498. if (!this.isVisible || this.notRenderable) {
  3499. return false;
  3500. }
  3501. if (!_super.prototype.contains.call(this, x, y)) {
  3502. return false;
  3503. }
  3504. // Checking backwards to pick closest first
  3505. for (var index = this._children.length - 1; index >= 0; index--) {
  3506. var child = this._children[index];
  3507. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3508. if (child.hoverCursor) {
  3509. this._host._changeCursor(child.hoverCursor);
  3510. }
  3511. return true;
  3512. }
  3513. }
  3514. if (!this.isHitTestVisible) {
  3515. return false;
  3516. }
  3517. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3518. };
  3519. /** @hidden */
  3520. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3521. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3522. this._measureForChildren.copyFrom(this._currentMeasure);
  3523. };
  3524. /** Releases associated resources */
  3525. Container.prototype.dispose = function () {
  3526. _super.prototype.dispose.call(this);
  3527. for (var index = this.children.length - 1; index >= 0; index--) {
  3528. this.children[index].dispose();
  3529. }
  3530. };
  3531. return Container;
  3532. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3533. /***/ }),
  3534. /***/ "./2D/controls/control.ts":
  3535. /*!********************************!*\
  3536. !*** ./2D/controls/control.ts ***!
  3537. \********************************/
  3538. /*! exports provided: Control */
  3539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3540. "use strict";
  3541. __webpack_require__.r(__webpack_exports__);
  3542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3543. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  3544. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3545. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3546. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3547. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3548. /**
  3549. * Root class used for all 2D controls
  3550. * @see http://doc.babylonjs.com/how_to/gui#controls
  3551. */
  3552. var Control = /** @class */ (function () {
  3553. // Functions
  3554. /**
  3555. * Creates a new control
  3556. * @param name defines the name of the control
  3557. */
  3558. function Control(
  3559. /** defines the name of the control */
  3560. name) {
  3561. this.name = name;
  3562. this._alpha = 1;
  3563. this._alphaSet = false;
  3564. this._zIndex = 0;
  3565. /** @hidden */
  3566. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3567. this._fontFamily = "Arial";
  3568. this._fontStyle = "";
  3569. this._fontWeight = "";
  3570. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3571. /** @hidden */
  3572. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3573. /** @hidden */
  3574. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3575. this._color = "";
  3576. this._style = null;
  3577. /** @hidden */
  3578. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3579. /** @hidden */
  3580. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3581. /** @hidden */
  3582. this._isDirty = true;
  3583. /** @hidden */
  3584. this._wasDirty = false;
  3585. /** @hidden */
  3586. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3587. /** @hidden */
  3588. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3589. /** @hidden */
  3590. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3591. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3592. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3593. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3594. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3595. /** @hidden */
  3596. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3597. /** @hidden */
  3598. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3599. this._scaleX = 1.0;
  3600. this._scaleY = 1.0;
  3601. this._rotation = 0;
  3602. this._transformCenterX = 0.5;
  3603. this._transformCenterY = 0.5;
  3604. /** @hidden */
  3605. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3606. /** @hidden */
  3607. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3608. /** @hidden */
  3609. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3610. this._isMatrixDirty = true;
  3611. this._isVisible = true;
  3612. this._isHighlighted = false;
  3613. this._fontSet = false;
  3614. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3615. this._downCount = 0;
  3616. this._enterCount = -1;
  3617. this._doNotRender = false;
  3618. this._downPointerIds = {};
  3619. this._isEnabled = true;
  3620. this._disabledColor = "#9a9a9a";
  3621. /** @hidden */
  3622. this._rebuildLayout = false;
  3623. /** @hidden */
  3624. this._isClipped = false;
  3625. /**
  3626. * Gets or sets an object used to store user defined information for the node
  3627. */
  3628. this.metadata = null;
  3629. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3630. this.isHitTestVisible = true;
  3631. /** Gets or sets a boolean indicating if the control can block pointer events */
  3632. this.isPointerBlocker = false;
  3633. /** Gets or sets a boolean indicating if the control can be focusable */
  3634. this.isFocusInvisible = false;
  3635. /**
  3636. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3637. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  3638. */
  3639. this.clipChildren = true;
  3640. /**
  3641. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3642. */
  3643. this.useBitmapCache = false;
  3644. this._shadowOffsetX = 0;
  3645. this._shadowOffsetY = 0;
  3646. this._shadowBlur = 0;
  3647. this._shadowColor = 'black';
  3648. /** Gets or sets the cursor to use when the control is hovered */
  3649. this.hoverCursor = "";
  3650. /** @hidden */
  3651. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3652. /** @hidden */
  3653. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3654. /**
  3655. * An event triggered when the pointer move over the control.
  3656. */
  3657. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3658. /**
  3659. * An event triggered when the pointer move out of the control.
  3660. */
  3661. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3662. /**
  3663. * An event triggered when the pointer taps the control
  3664. */
  3665. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3666. /**
  3667. * An event triggered when pointer up
  3668. */
  3669. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3670. /**
  3671. * An event triggered when a control is clicked on
  3672. */
  3673. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3674. /**
  3675. * An event triggered when pointer enters the control
  3676. */
  3677. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3678. /**
  3679. * An event triggered when the control is marked as dirty
  3680. */
  3681. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3682. /**
  3683. * An event triggered before drawing the control
  3684. */
  3685. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3686. /**
  3687. * An event triggered after the control was drawn
  3688. */
  3689. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3690. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3691. }
  3692. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3693. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3694. get: function () {
  3695. return this._shadowOffsetX;
  3696. },
  3697. set: function (value) {
  3698. if (this._shadowOffsetX === value) {
  3699. return;
  3700. }
  3701. this._shadowOffsetX = value;
  3702. this._markAsDirty();
  3703. },
  3704. enumerable: true,
  3705. configurable: true
  3706. });
  3707. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3708. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3709. get: function () {
  3710. return this._shadowOffsetY;
  3711. },
  3712. set: function (value) {
  3713. if (this._shadowOffsetY === value) {
  3714. return;
  3715. }
  3716. this._shadowOffsetY = value;
  3717. this._markAsDirty();
  3718. },
  3719. enumerable: true,
  3720. configurable: true
  3721. });
  3722. Object.defineProperty(Control.prototype, "shadowBlur", {
  3723. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3724. get: function () {
  3725. return this._shadowBlur;
  3726. },
  3727. set: function (value) {
  3728. if (this._shadowBlur === value) {
  3729. return;
  3730. }
  3731. this._shadowBlur = value;
  3732. this._markAsDirty();
  3733. },
  3734. enumerable: true,
  3735. configurable: true
  3736. });
  3737. Object.defineProperty(Control.prototype, "shadowColor", {
  3738. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3739. get: function () {
  3740. return this._shadowColor;
  3741. },
  3742. set: function (value) {
  3743. if (this._shadowColor === value) {
  3744. return;
  3745. }
  3746. this._shadowColor = value;
  3747. this._markAsDirty();
  3748. },
  3749. enumerable: true,
  3750. configurable: true
  3751. });
  3752. Object.defineProperty(Control.prototype, "typeName", {
  3753. // Properties
  3754. /** Gets the control type name */
  3755. get: function () {
  3756. return this._getTypeName();
  3757. },
  3758. enumerable: true,
  3759. configurable: true
  3760. });
  3761. /**
  3762. * Get the current class name of the control.
  3763. * @returns current class name
  3764. */
  3765. Control.prototype.getClassName = function () {
  3766. return this._getTypeName();
  3767. };
  3768. Object.defineProperty(Control.prototype, "host", {
  3769. /**
  3770. * Get the hosting AdvancedDynamicTexture
  3771. */
  3772. get: function () {
  3773. return this._host;
  3774. },
  3775. enumerable: true,
  3776. configurable: true
  3777. });
  3778. Object.defineProperty(Control.prototype, "fontOffset", {
  3779. /** Gets or set information about font offsets (used to render and align text) */
  3780. get: function () {
  3781. return this._fontOffset;
  3782. },
  3783. set: function (offset) {
  3784. this._fontOffset = offset;
  3785. },
  3786. enumerable: true,
  3787. configurable: true
  3788. });
  3789. Object.defineProperty(Control.prototype, "alpha", {
  3790. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3791. get: function () {
  3792. return this._alpha;
  3793. },
  3794. set: function (value) {
  3795. if (this._alpha === value) {
  3796. return;
  3797. }
  3798. this._alphaSet = true;
  3799. this._alpha = value;
  3800. this._markAsDirty();
  3801. },
  3802. enumerable: true,
  3803. configurable: true
  3804. });
  3805. Object.defineProperty(Control.prototype, "isHighlighted", {
  3806. /**
  3807. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3808. */
  3809. get: function () {
  3810. return this._isHighlighted;
  3811. },
  3812. set: function (value) {
  3813. if (this._isHighlighted === value) {
  3814. return;
  3815. }
  3816. this._isHighlighted = value;
  3817. this._markAsDirty();
  3818. },
  3819. enumerable: true,
  3820. configurable: true
  3821. });
  3822. Object.defineProperty(Control.prototype, "scaleX", {
  3823. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3824. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3825. */
  3826. get: function () {
  3827. return this._scaleX;
  3828. },
  3829. set: function (value) {
  3830. if (this._scaleX === value) {
  3831. return;
  3832. }
  3833. this._scaleX = value;
  3834. this._markAsDirty();
  3835. this._markMatrixAsDirty();
  3836. },
  3837. enumerable: true,
  3838. configurable: true
  3839. });
  3840. Object.defineProperty(Control.prototype, "scaleY", {
  3841. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3842. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3843. */
  3844. get: function () {
  3845. return this._scaleY;
  3846. },
  3847. set: function (value) {
  3848. if (this._scaleY === value) {
  3849. return;
  3850. }
  3851. this._scaleY = value;
  3852. this._markAsDirty();
  3853. this._markMatrixAsDirty();
  3854. },
  3855. enumerable: true,
  3856. configurable: true
  3857. });
  3858. Object.defineProperty(Control.prototype, "rotation", {
  3859. /** Gets or sets the rotation angle (0 by default)
  3860. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3861. */
  3862. get: function () {
  3863. return this._rotation;
  3864. },
  3865. set: function (value) {
  3866. if (this._rotation === value) {
  3867. return;
  3868. }
  3869. this._rotation = value;
  3870. this._markAsDirty();
  3871. this._markMatrixAsDirty();
  3872. },
  3873. enumerable: true,
  3874. configurable: true
  3875. });
  3876. Object.defineProperty(Control.prototype, "transformCenterY", {
  3877. /** Gets or sets the transformation center on Y axis (0 by default)
  3878. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3879. */
  3880. get: function () {
  3881. return this._transformCenterY;
  3882. },
  3883. set: function (value) {
  3884. if (this._transformCenterY === value) {
  3885. return;
  3886. }
  3887. this._transformCenterY = value;
  3888. this._markAsDirty();
  3889. this._markMatrixAsDirty();
  3890. },
  3891. enumerable: true,
  3892. configurable: true
  3893. });
  3894. Object.defineProperty(Control.prototype, "transformCenterX", {
  3895. /** Gets or sets the transformation center on X axis (0 by default)
  3896. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3897. */
  3898. get: function () {
  3899. return this._transformCenterX;
  3900. },
  3901. set: function (value) {
  3902. if (this._transformCenterX === value) {
  3903. return;
  3904. }
  3905. this._transformCenterX = value;
  3906. this._markAsDirty();
  3907. this._markMatrixAsDirty();
  3908. },
  3909. enumerable: true,
  3910. configurable: true
  3911. });
  3912. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3913. /**
  3914. * Gets or sets the horizontal alignment
  3915. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3916. */
  3917. get: function () {
  3918. return this._horizontalAlignment;
  3919. },
  3920. set: function (value) {
  3921. if (this._horizontalAlignment === value) {
  3922. return;
  3923. }
  3924. this._horizontalAlignment = value;
  3925. this._markAsDirty();
  3926. },
  3927. enumerable: true,
  3928. configurable: true
  3929. });
  3930. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3931. /**
  3932. * Gets or sets the vertical alignment
  3933. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3934. */
  3935. get: function () {
  3936. return this._verticalAlignment;
  3937. },
  3938. set: function (value) {
  3939. if (this._verticalAlignment === value) {
  3940. return;
  3941. }
  3942. this._verticalAlignment = value;
  3943. this._markAsDirty();
  3944. },
  3945. enumerable: true,
  3946. configurable: true
  3947. });
  3948. Object.defineProperty(Control.prototype, "width", {
  3949. /**
  3950. * Gets or sets control width
  3951. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3952. */
  3953. get: function () {
  3954. return this._width.toString(this._host);
  3955. },
  3956. set: function (value) {
  3957. if (this._width.toString(this._host) === value) {
  3958. return;
  3959. }
  3960. if (this._width.fromString(value)) {
  3961. this._markAsDirty();
  3962. }
  3963. },
  3964. enumerable: true,
  3965. configurable: true
  3966. });
  3967. Object.defineProperty(Control.prototype, "widthInPixels", {
  3968. /**
  3969. * Gets control width in pixel
  3970. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3971. */
  3972. get: function () {
  3973. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3974. },
  3975. enumerable: true,
  3976. configurable: true
  3977. });
  3978. Object.defineProperty(Control.prototype, "height", {
  3979. /**
  3980. * Gets or sets control height
  3981. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3982. */
  3983. get: function () {
  3984. return this._height.toString(this._host);
  3985. },
  3986. set: function (value) {
  3987. if (this._height.toString(this._host) === value) {
  3988. return;
  3989. }
  3990. if (this._height.fromString(value)) {
  3991. this._markAsDirty();
  3992. }
  3993. },
  3994. enumerable: true,
  3995. configurable: true
  3996. });
  3997. Object.defineProperty(Control.prototype, "heightInPixels", {
  3998. /**
  3999. * Gets control height in pixel
  4000. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4001. */
  4002. get: function () {
  4003. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4004. },
  4005. enumerable: true,
  4006. configurable: true
  4007. });
  4008. Object.defineProperty(Control.prototype, "fontFamily", {
  4009. /** Gets or set font family */
  4010. get: function () {
  4011. if (!this._fontSet) {
  4012. return "";
  4013. }
  4014. return this._fontFamily;
  4015. },
  4016. set: function (value) {
  4017. if (this._fontFamily === value) {
  4018. return;
  4019. }
  4020. this._fontFamily = value;
  4021. this._resetFontCache();
  4022. },
  4023. enumerable: true,
  4024. configurable: true
  4025. });
  4026. Object.defineProperty(Control.prototype, "fontStyle", {
  4027. /** Gets or sets font style */
  4028. get: function () {
  4029. return this._fontStyle;
  4030. },
  4031. set: function (value) {
  4032. if (this._fontStyle === value) {
  4033. return;
  4034. }
  4035. this._fontStyle = value;
  4036. this._resetFontCache();
  4037. },
  4038. enumerable: true,
  4039. configurable: true
  4040. });
  4041. Object.defineProperty(Control.prototype, "fontWeight", {
  4042. /** Gets or sets font weight */
  4043. get: function () {
  4044. return this._fontWeight;
  4045. },
  4046. set: function (value) {
  4047. if (this._fontWeight === value) {
  4048. return;
  4049. }
  4050. this._fontWeight = value;
  4051. this._resetFontCache();
  4052. },
  4053. enumerable: true,
  4054. configurable: true
  4055. });
  4056. Object.defineProperty(Control.prototype, "style", {
  4057. /**
  4058. * Gets or sets style
  4059. * @see http://doc.babylonjs.com/how_to/gui#styles
  4060. */
  4061. get: function () {
  4062. return this._style;
  4063. },
  4064. set: function (value) {
  4065. var _this = this;
  4066. if (this._style) {
  4067. this._style.onChangedObservable.remove(this._styleObserver);
  4068. this._styleObserver = null;
  4069. }
  4070. this._style = value;
  4071. if (this._style) {
  4072. this._styleObserver = this._style.onChangedObservable.add(function () {
  4073. _this._markAsDirty();
  4074. _this._resetFontCache();
  4075. });
  4076. }
  4077. this._markAsDirty();
  4078. this._resetFontCache();
  4079. },
  4080. enumerable: true,
  4081. configurable: true
  4082. });
  4083. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4084. /** @hidden */
  4085. get: function () {
  4086. return this._fontSize.isPercentage;
  4087. },
  4088. enumerable: true,
  4089. configurable: true
  4090. });
  4091. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4092. /** Gets font size in pixels */
  4093. get: function () {
  4094. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4095. if (fontSizeToUse.isPixel) {
  4096. return fontSizeToUse.getValue(this._host);
  4097. }
  4098. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4099. },
  4100. enumerable: true,
  4101. configurable: true
  4102. });
  4103. Object.defineProperty(Control.prototype, "fontSize", {
  4104. /** Gets or sets font size */
  4105. get: function () {
  4106. return this._fontSize.toString(this._host);
  4107. },
  4108. set: function (value) {
  4109. if (this._fontSize.toString(this._host) === value) {
  4110. return;
  4111. }
  4112. if (this._fontSize.fromString(value)) {
  4113. this._markAsDirty();
  4114. this._resetFontCache();
  4115. }
  4116. },
  4117. enumerable: true,
  4118. configurable: true
  4119. });
  4120. Object.defineProperty(Control.prototype, "color", {
  4121. /** Gets or sets foreground color */
  4122. get: function () {
  4123. return this._color;
  4124. },
  4125. set: function (value) {
  4126. if (this._color === value) {
  4127. return;
  4128. }
  4129. this._color = value;
  4130. this._markAsDirty();
  4131. },
  4132. enumerable: true,
  4133. configurable: true
  4134. });
  4135. Object.defineProperty(Control.prototype, "zIndex", {
  4136. /** Gets or sets z index which is used to reorder controls on the z axis */
  4137. get: function () {
  4138. return this._zIndex;
  4139. },
  4140. set: function (value) {
  4141. if (this.zIndex === value) {
  4142. return;
  4143. }
  4144. this._zIndex = value;
  4145. if (this.parent) {
  4146. this.parent._reOrderControl(this);
  4147. }
  4148. },
  4149. enumerable: true,
  4150. configurable: true
  4151. });
  4152. Object.defineProperty(Control.prototype, "notRenderable", {
  4153. /** Gets or sets a boolean indicating if the control can be rendered */
  4154. get: function () {
  4155. return this._doNotRender;
  4156. },
  4157. set: function (value) {
  4158. if (this._doNotRender === value) {
  4159. return;
  4160. }
  4161. this._doNotRender = value;
  4162. this._markAsDirty();
  4163. },
  4164. enumerable: true,
  4165. configurable: true
  4166. });
  4167. Object.defineProperty(Control.prototype, "isVisible", {
  4168. /** Gets or sets a boolean indicating if the control is visible */
  4169. get: function () {
  4170. return this._isVisible;
  4171. },
  4172. set: function (value) {
  4173. if (this._isVisible === value) {
  4174. return;
  4175. }
  4176. this._isVisible = value;
  4177. this._markAsDirty(true);
  4178. },
  4179. enumerable: true,
  4180. configurable: true
  4181. });
  4182. Object.defineProperty(Control.prototype, "isDirty", {
  4183. /** Gets a boolean indicating that the control needs to update its rendering */
  4184. get: function () {
  4185. return this._isDirty;
  4186. },
  4187. enumerable: true,
  4188. configurable: true
  4189. });
  4190. Object.defineProperty(Control.prototype, "linkedMesh", {
  4191. /**
  4192. * Gets the current linked mesh (or null if none)
  4193. */
  4194. get: function () {
  4195. return this._linkedMesh;
  4196. },
  4197. enumerable: true,
  4198. configurable: true
  4199. });
  4200. Object.defineProperty(Control.prototype, "paddingLeft", {
  4201. /**
  4202. * Gets or sets a value indicating the padding to use on the left of the control
  4203. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4204. */
  4205. get: function () {
  4206. return this._paddingLeft.toString(this._host);
  4207. },
  4208. set: function (value) {
  4209. if (this._paddingLeft.fromString(value)) {
  4210. this._markAsDirty();
  4211. }
  4212. },
  4213. enumerable: true,
  4214. configurable: true
  4215. });
  4216. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4217. /**
  4218. * Gets a value indicating the padding in pixels to use on the left of the control
  4219. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4220. */
  4221. get: function () {
  4222. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4223. },
  4224. enumerable: true,
  4225. configurable: true
  4226. });
  4227. Object.defineProperty(Control.prototype, "paddingRight", {
  4228. /**
  4229. * Gets or sets a value indicating the padding to use on the right of the control
  4230. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4231. */
  4232. get: function () {
  4233. return this._paddingRight.toString(this._host);
  4234. },
  4235. set: function (value) {
  4236. if (this._paddingRight.fromString(value)) {
  4237. this._markAsDirty();
  4238. }
  4239. },
  4240. enumerable: true,
  4241. configurable: true
  4242. });
  4243. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4244. /**
  4245. * Gets a value indicating the padding in pixels to use on the right of the control
  4246. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4247. */
  4248. get: function () {
  4249. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4250. },
  4251. enumerable: true,
  4252. configurable: true
  4253. });
  4254. Object.defineProperty(Control.prototype, "paddingTop", {
  4255. /**
  4256. * Gets or sets a value indicating the padding to use on the top of the control
  4257. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4258. */
  4259. get: function () {
  4260. return this._paddingTop.toString(this._host);
  4261. },
  4262. set: function (value) {
  4263. if (this._paddingTop.fromString(value)) {
  4264. this._markAsDirty();
  4265. }
  4266. },
  4267. enumerable: true,
  4268. configurable: true
  4269. });
  4270. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4271. /**
  4272. * Gets a value indicating the padding in pixels to use on the top of the control
  4273. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4274. */
  4275. get: function () {
  4276. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4277. },
  4278. enumerable: true,
  4279. configurable: true
  4280. });
  4281. Object.defineProperty(Control.prototype, "paddingBottom", {
  4282. /**
  4283. * Gets or sets a value indicating the padding to use on the bottom of the control
  4284. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4285. */
  4286. get: function () {
  4287. return this._paddingBottom.toString(this._host);
  4288. },
  4289. set: function (value) {
  4290. if (this._paddingBottom.fromString(value)) {
  4291. this._markAsDirty();
  4292. }
  4293. },
  4294. enumerable: true,
  4295. configurable: true
  4296. });
  4297. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4298. /**
  4299. * Gets a value indicating the padding in pixels to use on the bottom of the control
  4300. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4301. */
  4302. get: function () {
  4303. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4304. },
  4305. enumerable: true,
  4306. configurable: true
  4307. });
  4308. Object.defineProperty(Control.prototype, "left", {
  4309. /**
  4310. * Gets or sets a value indicating the left coordinate of the control
  4311. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4312. */
  4313. get: function () {
  4314. return this._left.toString(this._host);
  4315. },
  4316. set: function (value) {
  4317. if (this._left.fromString(value)) {
  4318. this._markAsDirty();
  4319. }
  4320. },
  4321. enumerable: true,
  4322. configurable: true
  4323. });
  4324. Object.defineProperty(Control.prototype, "leftInPixels", {
  4325. /**
  4326. * Gets a value indicating the left coordinate in pixels of the control
  4327. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4328. */
  4329. get: function () {
  4330. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4331. },
  4332. enumerable: true,
  4333. configurable: true
  4334. });
  4335. Object.defineProperty(Control.prototype, "top", {
  4336. /**
  4337. * Gets or sets a value indicating the top coordinate of the control
  4338. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4339. */
  4340. get: function () {
  4341. return this._top.toString(this._host);
  4342. },
  4343. set: function (value) {
  4344. if (this._top.fromString(value)) {
  4345. this._markAsDirty();
  4346. }
  4347. },
  4348. enumerable: true,
  4349. configurable: true
  4350. });
  4351. Object.defineProperty(Control.prototype, "topInPixels", {
  4352. /**
  4353. * Gets a value indicating the top coordinate in pixels of the control
  4354. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4355. */
  4356. get: function () {
  4357. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4358. },
  4359. enumerable: true,
  4360. configurable: true
  4361. });
  4362. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4363. /**
  4364. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4365. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4366. */
  4367. get: function () {
  4368. return this._linkOffsetX.toString(this._host);
  4369. },
  4370. set: function (value) {
  4371. if (this._linkOffsetX.fromString(value)) {
  4372. this._markAsDirty();
  4373. }
  4374. },
  4375. enumerable: true,
  4376. configurable: true
  4377. });
  4378. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4379. /**
  4380. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  4381. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4382. */
  4383. get: function () {
  4384. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4385. },
  4386. enumerable: true,
  4387. configurable: true
  4388. });
  4389. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4390. /**
  4391. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4392. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4393. */
  4394. get: function () {
  4395. return this._linkOffsetY.toString(this._host);
  4396. },
  4397. set: function (value) {
  4398. if (this._linkOffsetY.fromString(value)) {
  4399. this._markAsDirty();
  4400. }
  4401. },
  4402. enumerable: true,
  4403. configurable: true
  4404. });
  4405. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4406. /**
  4407. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  4408. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4409. */
  4410. get: function () {
  4411. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4412. },
  4413. enumerable: true,
  4414. configurable: true
  4415. });
  4416. Object.defineProperty(Control.prototype, "centerX", {
  4417. /** Gets the center coordinate on X axis */
  4418. get: function () {
  4419. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4420. },
  4421. enumerable: true,
  4422. configurable: true
  4423. });
  4424. Object.defineProperty(Control.prototype, "centerY", {
  4425. /** Gets the center coordinate on Y axis */
  4426. get: function () {
  4427. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4428. },
  4429. enumerable: true,
  4430. configurable: true
  4431. });
  4432. Object.defineProperty(Control.prototype, "isEnabled", {
  4433. /** Gets or sets if control is Enabled*/
  4434. get: function () {
  4435. return this._isEnabled;
  4436. },
  4437. set: function (value) {
  4438. if (this._isEnabled === value) {
  4439. return;
  4440. }
  4441. this._isEnabled = value;
  4442. this._markAsDirty();
  4443. },
  4444. enumerable: true,
  4445. configurable: true
  4446. });
  4447. Object.defineProperty(Control.prototype, "disabledColor", {
  4448. /** Gets or sets background color of control if it's disabled*/
  4449. get: function () {
  4450. return this._disabledColor;
  4451. },
  4452. set: function (value) {
  4453. if (this._disabledColor === value) {
  4454. return;
  4455. }
  4456. this._disabledColor = value;
  4457. this._markAsDirty();
  4458. },
  4459. enumerable: true,
  4460. configurable: true
  4461. });
  4462. /** @hidden */
  4463. Control.prototype._getTypeName = function () {
  4464. return "Control";
  4465. };
  4466. /**
  4467. * Gets the first ascendant in the hierarchy of the given type
  4468. * @param className defines the required type
  4469. * @returns the ascendant or null if not found
  4470. */
  4471. Control.prototype.getAscendantOfClass = function (className) {
  4472. if (!this.parent) {
  4473. return null;
  4474. }
  4475. if (this.parent.getClassName() === className) {
  4476. return this.parent;
  4477. }
  4478. return this.parent.getAscendantOfClass(className);
  4479. };
  4480. /** @hidden */
  4481. Control.prototype._resetFontCache = function () {
  4482. this._fontSet = true;
  4483. this._markAsDirty();
  4484. };
  4485. /**
  4486. * Determines if a container is an ascendant of the current control
  4487. * @param container defines the container to look for
  4488. * @returns true if the container is one of the ascendant of the control
  4489. */
  4490. Control.prototype.isAscendant = function (container) {
  4491. if (!this.parent) {
  4492. return false;
  4493. }
  4494. if (this.parent === container) {
  4495. return true;
  4496. }
  4497. return this.parent.isAscendant(container);
  4498. };
  4499. /**
  4500. * Gets coordinates in local control space
  4501. * @param globalCoordinates defines the coordinates to transform
  4502. * @returns the new coordinates in local space
  4503. */
  4504. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4505. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4506. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4507. return result;
  4508. };
  4509. /**
  4510. * Gets coordinates in local control space
  4511. * @param globalCoordinates defines the coordinates to transform
  4512. * @param result defines the target vector2 where to store the result
  4513. * @returns the current control
  4514. */
  4515. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4516. result.x = globalCoordinates.x - this._currentMeasure.left;
  4517. result.y = globalCoordinates.y - this._currentMeasure.top;
  4518. return this;
  4519. };
  4520. /**
  4521. * Gets coordinates in parent local control space
  4522. * @param globalCoordinates defines the coordinates to transform
  4523. * @returns the new coordinates in parent local space
  4524. */
  4525. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4526. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4527. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4528. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4529. return result;
  4530. };
  4531. /**
  4532. * Move the current control to a vector3 position projected onto the screen.
  4533. * @param position defines the target position
  4534. * @param scene defines the hosting scene
  4535. */
  4536. Control.prototype.moveToVector3 = function (position, scene) {
  4537. if (!this._host || this.parent !== this._host._rootContainer) {
  4538. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4539. return;
  4540. }
  4541. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4542. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4543. var globalViewport = this._host._getGlobalViewport(scene);
  4544. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4545. this._moveToProjectedPosition(projectedPosition);
  4546. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4547. this.notRenderable = true;
  4548. return;
  4549. }
  4550. this.notRenderable = false;
  4551. };
  4552. /** @hidden */
  4553. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4554. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4555. // Do nothing by default
  4556. };
  4557. /**
  4558. * Will return all controls that have this control as ascendant
  4559. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  4560. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  4561. * @return all child controls
  4562. */
  4563. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4564. var results = new Array();
  4565. this._getDescendants(results, directDescendantsOnly, predicate);
  4566. return results;
  4567. };
  4568. /**
  4569. * Link current control with a target mesh
  4570. * @param mesh defines the mesh to link with
  4571. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4572. */
  4573. Control.prototype.linkWithMesh = function (mesh) {
  4574. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4575. if (mesh) {
  4576. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4577. }
  4578. return;
  4579. }
  4580. var index = this._host._linkedControls.indexOf(this);
  4581. if (index !== -1) {
  4582. this._linkedMesh = mesh;
  4583. if (!mesh) {
  4584. this._host._linkedControls.splice(index, 1);
  4585. }
  4586. return;
  4587. }
  4588. else if (!mesh) {
  4589. return;
  4590. }
  4591. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4592. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4593. this._linkedMesh = mesh;
  4594. this._host._linkedControls.push(this);
  4595. };
  4596. /** @hidden */
  4597. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4598. var oldLeft = this._left.getValue(this._host);
  4599. var oldTop = this._top.getValue(this._host);
  4600. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4601. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4602. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4603. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4604. newLeft = oldLeft;
  4605. }
  4606. if (Math.abs(newTop - oldTop) < 0.5) {
  4607. newTop = oldTop;
  4608. }
  4609. }
  4610. this.left = newLeft + "px";
  4611. this.top = newTop + "px";
  4612. this._left.ignoreAdaptiveScaling = true;
  4613. this._top.ignoreAdaptiveScaling = true;
  4614. this._markAsDirty();
  4615. };
  4616. /** @hidden */
  4617. Control.prototype._offsetLeft = function (offset) {
  4618. this._isDirty = true;
  4619. this._currentMeasure.left += offset;
  4620. };
  4621. /** @hidden */
  4622. Control.prototype._offsetTop = function (offset) {
  4623. this._isDirty = true;
  4624. this._currentMeasure.top += offset;
  4625. };
  4626. /** @hidden */
  4627. Control.prototype._markMatrixAsDirty = function () {
  4628. this._isMatrixDirty = true;
  4629. this._flagDescendantsAsMatrixDirty();
  4630. };
  4631. /** @hidden */
  4632. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4633. // No child
  4634. };
  4635. /** @hidden */
  4636. Control.prototype._intersectsRect = function (rect) {
  4637. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4638. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4639. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4640. return false;
  4641. }
  4642. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4643. return false;
  4644. }
  4645. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4646. return false;
  4647. }
  4648. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4649. return false;
  4650. }
  4651. return true;
  4652. };
  4653. /** @hidden */
  4654. Control.prototype.invalidateRect = function () {
  4655. this._transform();
  4656. if (this.host && this.host.useInvalidateRectOptimization) {
  4657. // Rotate by transform to get the measure transformed to global space
  4658. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4659. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4660. // the previous measure is used to properly clear a control that is scaled down
  4661. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4662. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left), Math.floor(this._tmpMeasureA.top), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height));
  4663. }
  4664. };
  4665. /** @hidden */
  4666. Control.prototype._markAsDirty = function (force) {
  4667. if (force === void 0) { force = false; }
  4668. if (!this._isVisible && !force) {
  4669. return;
  4670. }
  4671. this._isDirty = true;
  4672. // Redraw only this rectangle
  4673. if (this._host) {
  4674. this._host.markAsDirty();
  4675. }
  4676. };
  4677. /** @hidden */
  4678. Control.prototype._markAllAsDirty = function () {
  4679. this._markAsDirty();
  4680. if (this._font) {
  4681. this._prepareFont();
  4682. }
  4683. };
  4684. /** @hidden */
  4685. Control.prototype._link = function (host) {
  4686. this._host = host;
  4687. if (this._host) {
  4688. this.uniqueId = this._host.getScene().getUniqueId();
  4689. }
  4690. };
  4691. /** @hidden */
  4692. Control.prototype._transform = function (context) {
  4693. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4694. return;
  4695. }
  4696. // postTranslate
  4697. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4698. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4699. if (context) {
  4700. context.translate(offsetX, offsetY);
  4701. // rotate
  4702. context.rotate(this._rotation);
  4703. // scale
  4704. context.scale(this._scaleX, this._scaleY);
  4705. // preTranslate
  4706. context.translate(-offsetX, -offsetY);
  4707. }
  4708. // Need to update matrices?
  4709. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4710. this._cachedOffsetX = offsetX;
  4711. this._cachedOffsetY = offsetY;
  4712. this._isMatrixDirty = false;
  4713. this._flagDescendantsAsMatrixDirty();
  4714. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4715. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4716. }
  4717. };
  4718. /** @hidden */
  4719. Control.prototype._renderHighlight = function (context) {
  4720. if (!this.isHighlighted) {
  4721. return;
  4722. }
  4723. context.save();
  4724. context.strokeStyle = "#4affff";
  4725. context.lineWidth = 2;
  4726. this._renderHighlightSpecific(context);
  4727. context.restore();
  4728. };
  4729. /** @hidden */
  4730. Control.prototype._renderHighlightSpecific = function (context) {
  4731. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4732. };
  4733. /** @hidden */
  4734. Control.prototype._applyStates = function (context) {
  4735. if (this._isFontSizeInPercentage) {
  4736. this._fontSet = true;
  4737. }
  4738. if (this._fontSet) {
  4739. this._prepareFont();
  4740. this._fontSet = false;
  4741. }
  4742. if (this._font) {
  4743. context.font = this._font;
  4744. }
  4745. if (this._color) {
  4746. context.fillStyle = this._color;
  4747. }
  4748. if (Control.AllowAlphaInheritance) {
  4749. context.globalAlpha *= this._alpha;
  4750. }
  4751. else if (this._alphaSet) {
  4752. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4753. }
  4754. };
  4755. /** @hidden */
  4756. Control.prototype._layout = function (parentMeasure, context) {
  4757. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4758. return false;
  4759. }
  4760. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4761. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4762. context.save();
  4763. this._applyStates(context);
  4764. var rebuildCount = 0;
  4765. do {
  4766. this._rebuildLayout = false;
  4767. this._processMeasures(parentMeasure, context);
  4768. rebuildCount++;
  4769. } while (this._rebuildLayout && rebuildCount < 3);
  4770. if (rebuildCount >= 3) {
  4771. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4772. }
  4773. context.restore();
  4774. this.invalidateRect();
  4775. this._evaluateClippingState(parentMeasure);
  4776. }
  4777. this._wasDirty = this._isDirty;
  4778. this._isDirty = false;
  4779. return true;
  4780. };
  4781. /** @hidden */
  4782. Control.prototype._processMeasures = function (parentMeasure, context) {
  4783. this._currentMeasure.copyFrom(parentMeasure);
  4784. // Let children take some pre-measurement actions
  4785. this._preMeasure(parentMeasure, context);
  4786. this._measure();
  4787. this._computeAlignment(parentMeasure, context);
  4788. // Convert to int values
  4789. this._currentMeasure.left = this._currentMeasure.left | 0;
  4790. this._currentMeasure.top = this._currentMeasure.top | 0;
  4791. this._currentMeasure.width = this._currentMeasure.width | 0;
  4792. this._currentMeasure.height = this._currentMeasure.height | 0;
  4793. // Let children add more features
  4794. this._additionalProcessing(parentMeasure, context);
  4795. this._cachedParentMeasure.copyFrom(parentMeasure);
  4796. if (this.onDirtyObservable.hasObservers()) {
  4797. this.onDirtyObservable.notifyObservers(this);
  4798. }
  4799. };
  4800. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4801. if (this.parent && this.parent.clipChildren) {
  4802. // Early clip
  4803. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4804. this._isClipped = true;
  4805. return;
  4806. }
  4807. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4808. this._isClipped = true;
  4809. return;
  4810. }
  4811. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4812. this._isClipped = true;
  4813. return;
  4814. }
  4815. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4816. this._isClipped = true;
  4817. return;
  4818. }
  4819. }
  4820. this._isClipped = false;
  4821. };
  4822. /** @hidden */
  4823. Control.prototype._measure = function () {
  4824. // Width / Height
  4825. if (this._width.isPixel) {
  4826. this._currentMeasure.width = this._width.getValue(this._host);
  4827. }
  4828. else {
  4829. this._currentMeasure.width *= this._width.getValue(this._host);
  4830. }
  4831. if (this._height.isPixel) {
  4832. this._currentMeasure.height = this._height.getValue(this._host);
  4833. }
  4834. else {
  4835. this._currentMeasure.height *= this._height.getValue(this._host);
  4836. }
  4837. };
  4838. /** @hidden */
  4839. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4840. var width = this._currentMeasure.width;
  4841. var height = this._currentMeasure.height;
  4842. var parentWidth = parentMeasure.width;
  4843. var parentHeight = parentMeasure.height;
  4844. // Left / top
  4845. var x = 0;
  4846. var y = 0;
  4847. switch (this.horizontalAlignment) {
  4848. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4849. x = 0;
  4850. break;
  4851. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4852. x = parentWidth - width;
  4853. break;
  4854. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4855. x = (parentWidth - width) / 2;
  4856. break;
  4857. }
  4858. switch (this.verticalAlignment) {
  4859. case Control.VERTICAL_ALIGNMENT_TOP:
  4860. y = 0;
  4861. break;
  4862. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4863. y = parentHeight - height;
  4864. break;
  4865. case Control.VERTICAL_ALIGNMENT_CENTER:
  4866. y = (parentHeight - height) / 2;
  4867. break;
  4868. }
  4869. if (this._paddingLeft.isPixel) {
  4870. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4871. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4872. }
  4873. else {
  4874. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4875. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4876. }
  4877. if (this._paddingRight.isPixel) {
  4878. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4879. }
  4880. else {
  4881. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4882. }
  4883. if (this._paddingTop.isPixel) {
  4884. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4885. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4886. }
  4887. else {
  4888. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4889. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4890. }
  4891. if (this._paddingBottom.isPixel) {
  4892. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4893. }
  4894. else {
  4895. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4896. }
  4897. if (this._left.isPixel) {
  4898. this._currentMeasure.left += this._left.getValue(this._host);
  4899. }
  4900. else {
  4901. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4902. }
  4903. if (this._top.isPixel) {
  4904. this._currentMeasure.top += this._top.getValue(this._host);
  4905. }
  4906. else {
  4907. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4908. }
  4909. this._currentMeasure.left += x;
  4910. this._currentMeasure.top += y;
  4911. };
  4912. /** @hidden */
  4913. Control.prototype._preMeasure = function (parentMeasure, context) {
  4914. // Do nothing
  4915. };
  4916. /** @hidden */
  4917. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4918. // Do nothing
  4919. };
  4920. /** @hidden */
  4921. Control.prototype._clipForChildren = function (context) {
  4922. // DO nothing
  4923. };
  4924. Control.prototype._clip = function (context, invalidatedRectangle) {
  4925. context.beginPath();
  4926. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4927. if (invalidatedRectangle) {
  4928. // Rotate the invalidated rect into the control's space
  4929. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  4930. // Get the intersection of the rect in context space and the current context
  4931. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  4932. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  4933. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  4934. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  4935. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  4936. Control._ClipMeasure.copyFrom(intersection);
  4937. }
  4938. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4939. var shadowOffsetX = this.shadowOffsetX;
  4940. var shadowOffsetY = this.shadowOffsetY;
  4941. var shadowBlur = this.shadowBlur;
  4942. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4943. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4944. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4945. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4946. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  4947. }
  4948. else {
  4949. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  4950. }
  4951. context.clip();
  4952. };
  4953. /** @hidden */
  4954. Control.prototype._render = function (context, invalidatedRectangle) {
  4955. if (!this.isVisible || this.notRenderable || this._isClipped) {
  4956. this._isDirty = false;
  4957. return false;
  4958. }
  4959. context.save();
  4960. this._applyStates(context);
  4961. // Transform
  4962. this._transform(context);
  4963. // Clip
  4964. if (this.clipChildren) {
  4965. this._clip(context, invalidatedRectangle);
  4966. }
  4967. if (this.onBeforeDrawObservable.hasObservers()) {
  4968. this.onBeforeDrawObservable.notifyObservers(this);
  4969. }
  4970. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  4971. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  4972. }
  4973. else {
  4974. this._draw(context, invalidatedRectangle);
  4975. }
  4976. if (this.useBitmapCache && this._wasDirty) {
  4977. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4978. }
  4979. this._renderHighlight(context);
  4980. if (this.onAfterDrawObservable.hasObservers()) {
  4981. this.onAfterDrawObservable.notifyObservers(this);
  4982. }
  4983. context.restore();
  4984. return true;
  4985. };
  4986. /** @hidden */
  4987. Control.prototype._draw = function (context, invalidatedRectangle) {
  4988. // Do nothing
  4989. };
  4990. /**
  4991. * Tests if a given coordinates belong to the current control
  4992. * @param x defines x coordinate to test
  4993. * @param y defines y coordinate to test
  4994. * @returns true if the coordinates are inside the control
  4995. */
  4996. Control.prototype.contains = function (x, y) {
  4997. // Invert transform
  4998. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  4999. x = this._transformedPosition.x;
  5000. y = this._transformedPosition.y;
  5001. // Check
  5002. if (x < this._currentMeasure.left) {
  5003. return false;
  5004. }
  5005. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5006. return false;
  5007. }
  5008. if (y < this._currentMeasure.top) {
  5009. return false;
  5010. }
  5011. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5012. return false;
  5013. }
  5014. if (this.isPointerBlocker) {
  5015. this._host._shouldBlockPointer = true;
  5016. }
  5017. return true;
  5018. };
  5019. /** @hidden */
  5020. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5021. if (!this._isEnabled) {
  5022. return false;
  5023. }
  5024. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5025. return false;
  5026. }
  5027. if (!this.contains(x, y)) {
  5028. return false;
  5029. }
  5030. this._processObservables(type, x, y, pointerId, buttonIndex);
  5031. return true;
  5032. };
  5033. /** @hidden */
  5034. Control.prototype._onPointerMove = function (target, coordinates) {
  5035. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5036. if (canNotify && this.parent != null) {
  5037. this.parent._onPointerMove(target, coordinates);
  5038. }
  5039. };
  5040. /** @hidden */
  5041. Control.prototype._onPointerEnter = function (target) {
  5042. if (!this._isEnabled) {
  5043. return false;
  5044. }
  5045. if (this._enterCount > 0) {
  5046. return false;
  5047. }
  5048. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5049. this._enterCount = 0;
  5050. }
  5051. this._enterCount++;
  5052. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5053. if (canNotify && this.parent != null) {
  5054. this.parent._onPointerEnter(target);
  5055. }
  5056. return true;
  5057. };
  5058. /** @hidden */
  5059. Control.prototype._onPointerOut = function (target) {
  5060. if (!this._isEnabled || target === this) {
  5061. return;
  5062. }
  5063. this._enterCount = 0;
  5064. var canNotify = true;
  5065. if (!target.isAscendant(this)) {
  5066. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5067. }
  5068. if (canNotify && this.parent != null) {
  5069. this.parent._onPointerOut(target);
  5070. }
  5071. };
  5072. /** @hidden */
  5073. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5074. // Prevent pointerout to lose control context.
  5075. // Event redundancy is checked inside the function.
  5076. this._onPointerEnter(this);
  5077. if (this._downCount !== 0) {
  5078. return false;
  5079. }
  5080. this._downCount++;
  5081. this._downPointerIds[pointerId] = true;
  5082. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5083. if (canNotify && this.parent != null) {
  5084. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5085. }
  5086. return true;
  5087. };
  5088. /** @hidden */
  5089. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5090. if (!this._isEnabled) {
  5091. return;
  5092. }
  5093. this._downCount = 0;
  5094. delete this._downPointerIds[pointerId];
  5095. var canNotifyClick = notifyClick;
  5096. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5097. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5098. }
  5099. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5100. if (canNotify && this.parent != null) {
  5101. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5102. }
  5103. };
  5104. /** @hidden */
  5105. Control.prototype._forcePointerUp = function (pointerId) {
  5106. if (pointerId === void 0) { pointerId = null; }
  5107. if (pointerId !== null) {
  5108. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5109. }
  5110. else {
  5111. for (var key in this._downPointerIds) {
  5112. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5113. }
  5114. }
  5115. };
  5116. /** @hidden */
  5117. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5118. if (!this._isEnabled) {
  5119. return false;
  5120. }
  5121. this._dummyVector2.copyFromFloats(x, y);
  5122. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5123. this._onPointerMove(this, this._dummyVector2);
  5124. var previousControlOver = this._host._lastControlOver[pointerId];
  5125. if (previousControlOver && previousControlOver !== this) {
  5126. previousControlOver._onPointerOut(this);
  5127. }
  5128. if (previousControlOver !== this) {
  5129. this._onPointerEnter(this);
  5130. }
  5131. this._host._lastControlOver[pointerId] = this;
  5132. return true;
  5133. }
  5134. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5135. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5136. this._host._registerLastControlDown(this, pointerId);
  5137. this._host._lastPickedControl = this;
  5138. return true;
  5139. }
  5140. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5141. if (this._host._lastControlDown[pointerId]) {
  5142. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5143. }
  5144. delete this._host._lastControlDown[pointerId];
  5145. return true;
  5146. }
  5147. return false;
  5148. };
  5149. Control.prototype._prepareFont = function () {
  5150. if (!this._font && !this._fontSet) {
  5151. return;
  5152. }
  5153. if (this._style) {
  5154. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5155. }
  5156. else {
  5157. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5158. }
  5159. this._fontOffset = Control._GetFontOffset(this._font);
  5160. };
  5161. /** Releases associated resources */
  5162. Control.prototype.dispose = function () {
  5163. this.onDirtyObservable.clear();
  5164. this.onBeforeDrawObservable.clear();
  5165. this.onAfterDrawObservable.clear();
  5166. this.onPointerDownObservable.clear();
  5167. this.onPointerEnterObservable.clear();
  5168. this.onPointerMoveObservable.clear();
  5169. this.onPointerOutObservable.clear();
  5170. this.onPointerUpObservable.clear();
  5171. this.onPointerClickObservable.clear();
  5172. if (this._styleObserver && this._style) {
  5173. this._style.onChangedObservable.remove(this._styleObserver);
  5174. this._styleObserver = null;
  5175. }
  5176. if (this.parent) {
  5177. this.parent.removeControl(this);
  5178. this.parent = null;
  5179. }
  5180. if (this._host) {
  5181. var index = this._host._linkedControls.indexOf(this);
  5182. if (index > -1) {
  5183. this.linkWithMesh(null);
  5184. }
  5185. }
  5186. };
  5187. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5188. /** HORIZONTAL_ALIGNMENT_LEFT */
  5189. get: function () {
  5190. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5191. },
  5192. enumerable: true,
  5193. configurable: true
  5194. });
  5195. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5196. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5197. get: function () {
  5198. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5199. },
  5200. enumerable: true,
  5201. configurable: true
  5202. });
  5203. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5204. /** HORIZONTAL_ALIGNMENT_CENTER */
  5205. get: function () {
  5206. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5207. },
  5208. enumerable: true,
  5209. configurable: true
  5210. });
  5211. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5212. /** VERTICAL_ALIGNMENT_TOP */
  5213. get: function () {
  5214. return Control._VERTICAL_ALIGNMENT_TOP;
  5215. },
  5216. enumerable: true,
  5217. configurable: true
  5218. });
  5219. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5220. /** VERTICAL_ALIGNMENT_BOTTOM */
  5221. get: function () {
  5222. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5223. },
  5224. enumerable: true,
  5225. configurable: true
  5226. });
  5227. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5228. /** VERTICAL_ALIGNMENT_CENTER */
  5229. get: function () {
  5230. return Control._VERTICAL_ALIGNMENT_CENTER;
  5231. },
  5232. enumerable: true,
  5233. configurable: true
  5234. });
  5235. /** @hidden */
  5236. Control._GetFontOffset = function (font) {
  5237. if (Control._FontHeightSizes[font]) {
  5238. return Control._FontHeightSizes[font];
  5239. }
  5240. var text = document.createElement("span");
  5241. text.innerHTML = "Hg";
  5242. text.style.font = font;
  5243. var block = document.createElement("div");
  5244. block.style.display = "inline-block";
  5245. block.style.width = "1px";
  5246. block.style.height = "0px";
  5247. block.style.verticalAlign = "bottom";
  5248. var div = document.createElement("div");
  5249. div.appendChild(text);
  5250. div.appendChild(block);
  5251. document.body.appendChild(div);
  5252. var fontAscent = 0;
  5253. var fontHeight = 0;
  5254. try {
  5255. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5256. block.style.verticalAlign = "baseline";
  5257. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5258. }
  5259. finally {
  5260. document.body.removeChild(div);
  5261. }
  5262. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5263. Control._FontHeightSizes[font] = result;
  5264. return result;
  5265. };
  5266. /** @hidden */
  5267. Control.drawEllipse = function (x, y, width, height, context) {
  5268. context.translate(x, y);
  5269. context.scale(width, height);
  5270. context.beginPath();
  5271. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5272. context.closePath();
  5273. context.scale(1 / width, 1 / height);
  5274. context.translate(-x, -y);
  5275. };
  5276. /**
  5277. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5278. */
  5279. Control.AllowAlphaInheritance = false;
  5280. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5281. // Statics
  5282. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5283. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5284. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5285. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5286. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5287. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5288. Control._FontHeightSizes = {};
  5289. /**
  5290. * Creates a stack panel that can be used to render headers
  5291. * @param control defines the control to associate with the header
  5292. * @param text defines the text of the header
  5293. * @param size defines the size of the header
  5294. * @param options defines options used to configure the header
  5295. * @returns a new StackPanel
  5296. * @ignore
  5297. * @hidden
  5298. */
  5299. Control.AddHeader = function () { };
  5300. return Control;
  5301. }());
  5302. /***/ }),
  5303. /***/ "./2D/controls/displayGrid.ts":
  5304. /*!************************************!*\
  5305. !*** ./2D/controls/displayGrid.ts ***!
  5306. \************************************/
  5307. /*! exports provided: DisplayGrid */
  5308. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5309. "use strict";
  5310. __webpack_require__.r(__webpack_exports__);
  5311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5312. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5313. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5314. /** Class used to render a grid */
  5315. var DisplayGrid = /** @class */ (function (_super) {
  5316. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5317. /**
  5318. * Creates a new GridDisplayRectangle
  5319. * @param name defines the control name
  5320. */
  5321. function DisplayGrid(name) {
  5322. var _this = _super.call(this, name) || this;
  5323. _this.name = name;
  5324. _this._cellWidth = 20;
  5325. _this._cellHeight = 20;
  5326. _this._minorLineTickness = 1;
  5327. _this._minorLineColor = "DarkGray";
  5328. _this._majorLineTickness = 2;
  5329. _this._majorLineColor = "White";
  5330. _this._majorLineFrequency = 5;
  5331. _this._background = "Black";
  5332. _this._displayMajorLines = true;
  5333. _this._displayMinorLines = true;
  5334. return _this;
  5335. }
  5336. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5337. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5338. get: function () {
  5339. return this._displayMinorLines;
  5340. },
  5341. set: function (value) {
  5342. if (this._displayMinorLines === value) {
  5343. return;
  5344. }
  5345. this._displayMinorLines = value;
  5346. this._markAsDirty();
  5347. },
  5348. enumerable: true,
  5349. configurable: true
  5350. });
  5351. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5352. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5353. get: function () {
  5354. return this._displayMajorLines;
  5355. },
  5356. set: function (value) {
  5357. if (this._displayMajorLines === value) {
  5358. return;
  5359. }
  5360. this._displayMajorLines = value;
  5361. this._markAsDirty();
  5362. },
  5363. enumerable: true,
  5364. configurable: true
  5365. });
  5366. Object.defineProperty(DisplayGrid.prototype, "background", {
  5367. /** Gets or sets background color (Black by default) */
  5368. get: function () {
  5369. return this._background;
  5370. },
  5371. set: function (value) {
  5372. if (this._background === value) {
  5373. return;
  5374. }
  5375. this._background = value;
  5376. this._markAsDirty();
  5377. },
  5378. enumerable: true,
  5379. configurable: true
  5380. });
  5381. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5382. /** Gets or sets the width of each cell (20 by default) */
  5383. get: function () {
  5384. return this._cellWidth;
  5385. },
  5386. set: function (value) {
  5387. this._cellWidth = value;
  5388. this._markAsDirty();
  5389. },
  5390. enumerable: true,
  5391. configurable: true
  5392. });
  5393. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5394. /** Gets or sets the height of each cell (20 by default) */
  5395. get: function () {
  5396. return this._cellHeight;
  5397. },
  5398. set: function (value) {
  5399. this._cellHeight = value;
  5400. this._markAsDirty();
  5401. },
  5402. enumerable: true,
  5403. configurable: true
  5404. });
  5405. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5406. /** Gets or sets the tickness of minor lines (1 by default) */
  5407. get: function () {
  5408. return this._minorLineTickness;
  5409. },
  5410. set: function (value) {
  5411. this._minorLineTickness = value;
  5412. this._markAsDirty();
  5413. },
  5414. enumerable: true,
  5415. configurable: true
  5416. });
  5417. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5418. /** Gets or sets the color of minor lines (DarkGray by default) */
  5419. get: function () {
  5420. return this._minorLineColor;
  5421. },
  5422. set: function (value) {
  5423. this._minorLineColor = value;
  5424. this._markAsDirty();
  5425. },
  5426. enumerable: true,
  5427. configurable: true
  5428. });
  5429. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5430. /** Gets or sets the tickness of major lines (2 by default) */
  5431. get: function () {
  5432. return this._majorLineTickness;
  5433. },
  5434. set: function (value) {
  5435. this._majorLineTickness = value;
  5436. this._markAsDirty();
  5437. },
  5438. enumerable: true,
  5439. configurable: true
  5440. });
  5441. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5442. /** Gets or sets the color of major lines (White by default) */
  5443. get: function () {
  5444. return this._majorLineColor;
  5445. },
  5446. set: function (value) {
  5447. this._majorLineColor = value;
  5448. this._markAsDirty();
  5449. },
  5450. enumerable: true,
  5451. configurable: true
  5452. });
  5453. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5454. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5455. get: function () {
  5456. return this._majorLineFrequency;
  5457. },
  5458. set: function (value) {
  5459. this._majorLineFrequency = value;
  5460. this._markAsDirty();
  5461. },
  5462. enumerable: true,
  5463. configurable: true
  5464. });
  5465. DisplayGrid.prototype._draw = function (context) {
  5466. context.save();
  5467. this._applyStates(context);
  5468. if (this._isEnabled) {
  5469. if (this._background) {
  5470. context.fillStyle = this._background;
  5471. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5472. }
  5473. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5474. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5475. // Minor lines
  5476. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5477. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5478. if (this._displayMinorLines) {
  5479. context.strokeStyle = this._minorLineColor;
  5480. context.lineWidth = this._minorLineTickness;
  5481. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5482. var cellX = left + x * this.cellWidth;
  5483. context.beginPath();
  5484. context.moveTo(cellX, this._currentMeasure.top);
  5485. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5486. context.stroke();
  5487. }
  5488. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5489. var cellY = top_1 + y * this.cellHeight;
  5490. context.beginPath();
  5491. context.moveTo(this._currentMeasure.left, cellY);
  5492. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5493. context.stroke();
  5494. }
  5495. }
  5496. // Major lines
  5497. if (this._displayMajorLines) {
  5498. context.strokeStyle = this._majorLineColor;
  5499. context.lineWidth = this._majorLineTickness;
  5500. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5501. var cellX = left + x * this.cellWidth;
  5502. context.beginPath();
  5503. context.moveTo(cellX, this._currentMeasure.top);
  5504. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5505. context.stroke();
  5506. }
  5507. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5508. var cellY = top_1 + y * this.cellHeight;
  5509. context.moveTo(this._currentMeasure.left, cellY);
  5510. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5511. context.closePath();
  5512. context.stroke();
  5513. }
  5514. }
  5515. }
  5516. context.restore();
  5517. };
  5518. DisplayGrid.prototype._getTypeName = function () {
  5519. return "DisplayGrid";
  5520. };
  5521. return DisplayGrid;
  5522. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5523. /***/ }),
  5524. /***/ "./2D/controls/ellipse.ts":
  5525. /*!********************************!*\
  5526. !*** ./2D/controls/ellipse.ts ***!
  5527. \********************************/
  5528. /*! exports provided: Ellipse */
  5529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5530. "use strict";
  5531. __webpack_require__.r(__webpack_exports__);
  5532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5533. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5534. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5535. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5536. /** Class used to create 2D ellipse containers */
  5537. var Ellipse = /** @class */ (function (_super) {
  5538. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5539. /**
  5540. * Creates a new Ellipse
  5541. * @param name defines the control name
  5542. */
  5543. function Ellipse(name) {
  5544. var _this = _super.call(this, name) || this;
  5545. _this.name = name;
  5546. _this._thickness = 1;
  5547. return _this;
  5548. }
  5549. Object.defineProperty(Ellipse.prototype, "thickness", {
  5550. /** Gets or sets border thickness */
  5551. get: function () {
  5552. return this._thickness;
  5553. },
  5554. set: function (value) {
  5555. if (this._thickness === value) {
  5556. return;
  5557. }
  5558. this._thickness = value;
  5559. this._markAsDirty();
  5560. },
  5561. enumerable: true,
  5562. configurable: true
  5563. });
  5564. Ellipse.prototype._getTypeName = function () {
  5565. return "Ellipse";
  5566. };
  5567. Ellipse.prototype._localDraw = function (context) {
  5568. context.save();
  5569. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5570. context.shadowColor = this.shadowColor;
  5571. context.shadowBlur = this.shadowBlur;
  5572. context.shadowOffsetX = this.shadowOffsetX;
  5573. context.shadowOffsetY = this.shadowOffsetY;
  5574. }
  5575. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  5576. if (this._background) {
  5577. context.fillStyle = this._background;
  5578. context.fill();
  5579. }
  5580. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5581. context.shadowBlur = 0;
  5582. context.shadowOffsetX = 0;
  5583. context.shadowOffsetY = 0;
  5584. }
  5585. if (this._thickness) {
  5586. if (this.color) {
  5587. context.strokeStyle = this.color;
  5588. }
  5589. context.lineWidth = this._thickness;
  5590. context.stroke();
  5591. }
  5592. context.restore();
  5593. };
  5594. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5595. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5596. this._measureForChildren.width -= 2 * this._thickness;
  5597. this._measureForChildren.height -= 2 * this._thickness;
  5598. this._measureForChildren.left += this._thickness;
  5599. this._measureForChildren.top += this._thickness;
  5600. };
  5601. Ellipse.prototype._clipForChildren = function (context) {
  5602. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2, this._currentMeasure.height / 2, context);
  5603. context.clip();
  5604. };
  5605. return Ellipse;
  5606. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5607. /***/ }),
  5608. /***/ "./2D/controls/grid.ts":
  5609. /*!*****************************!*\
  5610. !*** ./2D/controls/grid.ts ***!
  5611. \*****************************/
  5612. /*! exports provided: Grid */
  5613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5614. "use strict";
  5615. __webpack_require__.r(__webpack_exports__);
  5616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5617. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5618. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5619. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5620. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5621. /**
  5622. * Class used to create a 2D grid container
  5623. */
  5624. var Grid = /** @class */ (function (_super) {
  5625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5626. /**
  5627. * Creates a new Grid
  5628. * @param name defines control name
  5629. */
  5630. function Grid(name) {
  5631. var _this = _super.call(this, name) || this;
  5632. _this.name = name;
  5633. _this._rowDefinitions = new Array();
  5634. _this._columnDefinitions = new Array();
  5635. _this._cells = {};
  5636. _this._childControls = new Array();
  5637. return _this;
  5638. }
  5639. Object.defineProperty(Grid.prototype, "columnCount", {
  5640. /**
  5641. * Gets the number of columns
  5642. */
  5643. get: function () {
  5644. return this._columnDefinitions.length;
  5645. },
  5646. enumerable: true,
  5647. configurable: true
  5648. });
  5649. Object.defineProperty(Grid.prototype, "rowCount", {
  5650. /**
  5651. * Gets the number of rows
  5652. */
  5653. get: function () {
  5654. return this._rowDefinitions.length;
  5655. },
  5656. enumerable: true,
  5657. configurable: true
  5658. });
  5659. Object.defineProperty(Grid.prototype, "children", {
  5660. /** Gets the list of children */
  5661. get: function () {
  5662. return this._childControls;
  5663. },
  5664. enumerable: true,
  5665. configurable: true
  5666. });
  5667. /**
  5668. * Gets the definition of a specific row
  5669. * @param index defines the index of the row
  5670. * @returns the row definition
  5671. */
  5672. Grid.prototype.getRowDefinition = function (index) {
  5673. if (index < 0 || index >= this._rowDefinitions.length) {
  5674. return null;
  5675. }
  5676. return this._rowDefinitions[index];
  5677. };
  5678. /**
  5679. * Gets the definition of a specific column
  5680. * @param index defines the index of the column
  5681. * @returns the column definition
  5682. */
  5683. Grid.prototype.getColumnDefinition = function (index) {
  5684. if (index < 0 || index >= this._columnDefinitions.length) {
  5685. return null;
  5686. }
  5687. return this._columnDefinitions[index];
  5688. };
  5689. /**
  5690. * Adds a new row to the grid
  5691. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5692. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5693. * @returns the current grid
  5694. */
  5695. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5696. if (isPixel === void 0) { isPixel = false; }
  5697. this._rowDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5698. this._markAsDirty();
  5699. return this;
  5700. };
  5701. /**
  5702. * Adds a new column to the grid
  5703. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5704. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5705. * @returns the current grid
  5706. */
  5707. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5708. if (isPixel === void 0) { isPixel = false; }
  5709. this._columnDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5710. this._markAsDirty();
  5711. return this;
  5712. };
  5713. /**
  5714. * Update a row definition
  5715. * @param index defines the index of the row to update
  5716. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5717. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5718. * @returns the current grid
  5719. */
  5720. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5721. if (isPixel === void 0) { isPixel = false; }
  5722. if (index < 0 || index >= this._rowDefinitions.length) {
  5723. return this;
  5724. }
  5725. var current = this._rowDefinitions[index];
  5726. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5727. return this;
  5728. }
  5729. this._rowDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5730. this._markAsDirty();
  5731. return this;
  5732. };
  5733. /**
  5734. * Update a column definition
  5735. * @param index defines the index of the column to update
  5736. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5737. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5738. * @returns the current grid
  5739. */
  5740. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5741. if (isPixel === void 0) { isPixel = false; }
  5742. if (index < 0 || index >= this._columnDefinitions.length) {
  5743. return this;
  5744. }
  5745. var current = this._columnDefinitions[index];
  5746. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5747. return this;
  5748. }
  5749. this._columnDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5750. this._markAsDirty();
  5751. return this;
  5752. };
  5753. /**
  5754. * Gets the list of children stored in a specific cell
  5755. * @param row defines the row to check
  5756. * @param column defines the column to check
  5757. * @returns the list of controls
  5758. */
  5759. Grid.prototype.getChildrenAt = function (row, column) {
  5760. var cell = this._cells[row + ":" + column];
  5761. if (!cell) {
  5762. return null;
  5763. }
  5764. return cell.children;
  5765. };
  5766. /**
  5767. * Gets a string representing the child cell info (row x column)
  5768. * @param child defines the control to get info from
  5769. * @returns a string containing the child cell info (row x column)
  5770. */
  5771. Grid.prototype.getChildCellInfo = function (child) {
  5772. return child._tag;
  5773. };
  5774. Grid.prototype._removeCell = function (cell, key) {
  5775. if (!cell) {
  5776. return;
  5777. }
  5778. _super.prototype.removeControl.call(this, cell);
  5779. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5780. var control = _a[_i];
  5781. var childIndex = this._childControls.indexOf(control);
  5782. if (childIndex !== -1) {
  5783. this._childControls.splice(childIndex, 1);
  5784. }
  5785. }
  5786. delete this._cells[key];
  5787. };
  5788. Grid.prototype._offsetCell = function (previousKey, key) {
  5789. if (!this._cells[key]) {
  5790. return;
  5791. }
  5792. this._cells[previousKey] = this._cells[key];
  5793. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5794. var control = _a[_i];
  5795. control._tag = previousKey;
  5796. }
  5797. delete this._cells[key];
  5798. };
  5799. /**
  5800. * Remove a column definition at specified index
  5801. * @param index defines the index of the column to remove
  5802. * @returns the current grid
  5803. */
  5804. Grid.prototype.removeColumnDefinition = function (index) {
  5805. if (index < 0 || index >= this._columnDefinitions.length) {
  5806. return this;
  5807. }
  5808. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5809. var key = x + ":" + index;
  5810. var cell = this._cells[key];
  5811. this._removeCell(cell, key);
  5812. }
  5813. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5814. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5815. var previousKey = x + ":" + (y - 1);
  5816. var key = x + ":" + y;
  5817. this._offsetCell(previousKey, key);
  5818. }
  5819. }
  5820. this._columnDefinitions.splice(index, 1);
  5821. this._markAsDirty();
  5822. return this;
  5823. };
  5824. /**
  5825. * Remove a row definition at specified index
  5826. * @param index defines the index of the row to remove
  5827. * @returns the current grid
  5828. */
  5829. Grid.prototype.removeRowDefinition = function (index) {
  5830. if (index < 0 || index >= this._rowDefinitions.length) {
  5831. return this;
  5832. }
  5833. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5834. var key = index + ":" + y;
  5835. var cell = this._cells[key];
  5836. this._removeCell(cell, key);
  5837. }
  5838. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5839. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5840. var previousKey = x - 1 + ":" + y;
  5841. var key = x + ":" + y;
  5842. this._offsetCell(previousKey, key);
  5843. }
  5844. }
  5845. this._rowDefinitions.splice(index, 1);
  5846. this._markAsDirty();
  5847. return this;
  5848. };
  5849. /**
  5850. * Adds a new control to the current grid
  5851. * @param control defines the control to add
  5852. * @param row defines the row where to add the control (0 by default)
  5853. * @param column defines the column where to add the control (0 by default)
  5854. * @returns the current grid
  5855. */
  5856. Grid.prototype.addControl = function (control, row, column) {
  5857. if (row === void 0) { row = 0; }
  5858. if (column === void 0) { column = 0; }
  5859. if (this._rowDefinitions.length === 0) {
  5860. // Add default row definition
  5861. this.addRowDefinition(1, false);
  5862. }
  5863. if (this._columnDefinitions.length === 0) {
  5864. // Add default column definition
  5865. this.addColumnDefinition(1, false);
  5866. }
  5867. var x = Math.min(row, this._rowDefinitions.length - 1);
  5868. var y = Math.min(column, this._columnDefinitions.length - 1);
  5869. var key = x + ":" + y;
  5870. var goodContainer = this._cells[key];
  5871. if (!goodContainer) {
  5872. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5873. this._cells[key] = goodContainer;
  5874. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5875. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5876. _super.prototype.addControl.call(this, goodContainer);
  5877. }
  5878. goodContainer.addControl(control);
  5879. this._childControls.push(control);
  5880. control._tag = key;
  5881. control.parent = this;
  5882. this._markAsDirty();
  5883. return this;
  5884. };
  5885. /**
  5886. * Removes a control from the current container
  5887. * @param control defines the control to remove
  5888. * @returns the current container
  5889. */
  5890. Grid.prototype.removeControl = function (control) {
  5891. var index = this._childControls.indexOf(control);
  5892. if (index !== -1) {
  5893. this._childControls.splice(index, 1);
  5894. }
  5895. var cell = this._cells[control._tag];
  5896. if (cell) {
  5897. cell.removeControl(control);
  5898. }
  5899. this._markAsDirty();
  5900. return this;
  5901. };
  5902. Grid.prototype._getTypeName = function () {
  5903. return "Grid";
  5904. };
  5905. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5906. var widths = [];
  5907. var heights = [];
  5908. var lefts = [];
  5909. var tops = [];
  5910. var availableWidth = this._currentMeasure.width;
  5911. var globalWidthPercentage = 0;
  5912. var availableHeight = this._currentMeasure.height;
  5913. var globalHeightPercentage = 0;
  5914. // Heights
  5915. var index = 0;
  5916. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  5917. var value = _a[_i];
  5918. if (value.isPixel) {
  5919. var height = value.getValue(this._host);
  5920. availableHeight -= height;
  5921. heights[index] = height;
  5922. }
  5923. else {
  5924. globalHeightPercentage += value.internalValue;
  5925. }
  5926. index++;
  5927. }
  5928. var top = 0;
  5929. index = 0;
  5930. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  5931. var value = _c[_b];
  5932. tops.push(top);
  5933. if (!value.isPixel) {
  5934. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  5935. top += height;
  5936. heights[index] = height;
  5937. }
  5938. else {
  5939. top += value.getValue(this._host);
  5940. }
  5941. index++;
  5942. }
  5943. // Widths
  5944. index = 0;
  5945. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  5946. var value = _e[_d];
  5947. if (value.isPixel) {
  5948. var width = value.getValue(this._host);
  5949. availableWidth -= width;
  5950. widths[index] = width;
  5951. }
  5952. else {
  5953. globalWidthPercentage += value.internalValue;
  5954. }
  5955. index++;
  5956. }
  5957. var left = 0;
  5958. index = 0;
  5959. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  5960. var value = _g[_f];
  5961. lefts.push(left);
  5962. if (!value.isPixel) {
  5963. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  5964. left += width;
  5965. widths[index] = width;
  5966. }
  5967. else {
  5968. left += value.getValue(this._host);
  5969. }
  5970. index++;
  5971. }
  5972. definitionCallback(lefts, tops, widths, heights);
  5973. };
  5974. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  5975. var _this = this;
  5976. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  5977. // Setting child sizes
  5978. for (var key in _this._cells) {
  5979. if (!_this._cells.hasOwnProperty(key)) {
  5980. continue;
  5981. }
  5982. var split = key.split(":");
  5983. var x = parseInt(split[0]);
  5984. var y = parseInt(split[1]);
  5985. var cell = _this._cells[key];
  5986. cell.left = lefts[y] + "px";
  5987. cell.top = tops[x] + "px";
  5988. cell.width = widths[y] + "px";
  5989. cell.height = heights[x] + "px";
  5990. }
  5991. });
  5992. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5993. };
  5994. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  5995. for (var key in this._cells) {
  5996. if (!this._cells.hasOwnProperty(key)) {
  5997. continue;
  5998. }
  5999. var child = this._cells[key];
  6000. child._markMatrixAsDirty();
  6001. }
  6002. };
  6003. Grid.prototype._renderHighlightSpecific = function (context) {
  6004. var _this = this;
  6005. _super.prototype._renderHighlightSpecific.call(this, context);
  6006. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6007. // Columns
  6008. for (var index = 0; index < lefts.length; index++) {
  6009. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6010. context.beginPath();
  6011. context.moveTo(left, _this._currentMeasure.top);
  6012. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6013. context.stroke();
  6014. }
  6015. // Rows
  6016. for (var index = 0; index < tops.length; index++) {
  6017. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6018. context.beginPath();
  6019. context.moveTo(_this._currentMeasure.left, top_1);
  6020. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6021. context.stroke();
  6022. }
  6023. });
  6024. context.restore();
  6025. };
  6026. /** Releases associated resources */
  6027. Grid.prototype.dispose = function () {
  6028. _super.prototype.dispose.call(this);
  6029. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6030. var control = _a[_i];
  6031. control.dispose();
  6032. }
  6033. this._childControls = [];
  6034. };
  6035. return Grid;
  6036. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6037. /***/ }),
  6038. /***/ "./2D/controls/image.ts":
  6039. /*!******************************!*\
  6040. !*** ./2D/controls/image.ts ***!
  6041. \******************************/
  6042. /*! exports provided: Image */
  6043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6044. "use strict";
  6045. __webpack_require__.r(__webpack_exports__);
  6046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6047. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6048. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6049. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6050. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6051. /**
  6052. * Class used to create 2D images
  6053. */
  6054. var Image = /** @class */ (function (_super) {
  6055. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6056. /**
  6057. * Creates a new Image
  6058. * @param name defines the control name
  6059. * @param url defines the image url
  6060. */
  6061. function Image(name, url) {
  6062. if (url === void 0) { url = null; }
  6063. var _this = _super.call(this, name) || this;
  6064. _this.name = name;
  6065. _this._loaded = false;
  6066. _this._stretch = Image.STRETCH_FILL;
  6067. _this._autoScale = false;
  6068. _this._sourceLeft = 0;
  6069. _this._sourceTop = 0;
  6070. _this._sourceWidth = 0;
  6071. _this._sourceHeight = 0;
  6072. _this._cellWidth = 0;
  6073. _this._cellHeight = 0;
  6074. _this._cellId = -1;
  6075. _this._populateNinePatchSlicesFromImage = false;
  6076. /**
  6077. * Observable notified when the content is loaded
  6078. */
  6079. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6080. _this.source = url;
  6081. return _this;
  6082. }
  6083. Object.defineProperty(Image.prototype, "isLoaded", {
  6084. /**
  6085. * Gets a boolean indicating that the content is loaded
  6086. */
  6087. get: function () {
  6088. return this._loaded;
  6089. },
  6090. enumerable: true,
  6091. configurable: true
  6092. });
  6093. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6094. /**
  6095. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6096. */
  6097. get: function () {
  6098. return this._populateNinePatchSlicesFromImage;
  6099. },
  6100. set: function (value) {
  6101. if (this._populateNinePatchSlicesFromImage === value) {
  6102. return;
  6103. }
  6104. this._populateNinePatchSlicesFromImage = value;
  6105. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6106. this._extractNinePatchSliceDataFromImage();
  6107. }
  6108. },
  6109. enumerable: true,
  6110. configurable: true
  6111. });
  6112. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6113. /**
  6114. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6115. * Beware using this as this will comsume more memory as the image has to be stored twice
  6116. */
  6117. get: function () {
  6118. return this._detectPointerOnOpaqueOnly;
  6119. },
  6120. set: function (value) {
  6121. if (this._detectPointerOnOpaqueOnly === value) {
  6122. return;
  6123. }
  6124. this._detectPointerOnOpaqueOnly = value;
  6125. },
  6126. enumerable: true,
  6127. configurable: true
  6128. });
  6129. Object.defineProperty(Image.prototype, "sliceLeft", {
  6130. /**
  6131. * Gets or sets the left value for slicing (9-patch)
  6132. */
  6133. get: function () {
  6134. return this._sliceLeft;
  6135. },
  6136. set: function (value) {
  6137. if (this._sliceLeft === value) {
  6138. return;
  6139. }
  6140. this._sliceLeft = value;
  6141. this._markAsDirty();
  6142. },
  6143. enumerable: true,
  6144. configurable: true
  6145. });
  6146. Object.defineProperty(Image.prototype, "sliceRight", {
  6147. /**
  6148. * Gets or sets the right value for slicing (9-patch)
  6149. */
  6150. get: function () {
  6151. return this._sliceRight;
  6152. },
  6153. set: function (value) {
  6154. if (this._sliceRight === value) {
  6155. return;
  6156. }
  6157. this._sliceRight = value;
  6158. this._markAsDirty();
  6159. },
  6160. enumerable: true,
  6161. configurable: true
  6162. });
  6163. Object.defineProperty(Image.prototype, "sliceTop", {
  6164. /**
  6165. * Gets or sets the top value for slicing (9-patch)
  6166. */
  6167. get: function () {
  6168. return this._sliceTop;
  6169. },
  6170. set: function (value) {
  6171. if (this._sliceTop === value) {
  6172. return;
  6173. }
  6174. this._sliceTop = value;
  6175. this._markAsDirty();
  6176. },
  6177. enumerable: true,
  6178. configurable: true
  6179. });
  6180. Object.defineProperty(Image.prototype, "sliceBottom", {
  6181. /**
  6182. * Gets or sets the bottom value for slicing (9-patch)
  6183. */
  6184. get: function () {
  6185. return this._sliceBottom;
  6186. },
  6187. set: function (value) {
  6188. if (this._sliceBottom === value) {
  6189. return;
  6190. }
  6191. this._sliceBottom = value;
  6192. this._markAsDirty();
  6193. },
  6194. enumerable: true,
  6195. configurable: true
  6196. });
  6197. Object.defineProperty(Image.prototype, "sourceLeft", {
  6198. /**
  6199. * Gets or sets the left coordinate in the source image
  6200. */
  6201. get: function () {
  6202. return this._sourceLeft;
  6203. },
  6204. set: function (value) {
  6205. if (this._sourceLeft === value) {
  6206. return;
  6207. }
  6208. this._sourceLeft = value;
  6209. this._markAsDirty();
  6210. },
  6211. enumerable: true,
  6212. configurable: true
  6213. });
  6214. Object.defineProperty(Image.prototype, "sourceTop", {
  6215. /**
  6216. * Gets or sets the top coordinate in the source image
  6217. */
  6218. get: function () {
  6219. return this._sourceTop;
  6220. },
  6221. set: function (value) {
  6222. if (this._sourceTop === value) {
  6223. return;
  6224. }
  6225. this._sourceTop = value;
  6226. this._markAsDirty();
  6227. },
  6228. enumerable: true,
  6229. configurable: true
  6230. });
  6231. Object.defineProperty(Image.prototype, "sourceWidth", {
  6232. /**
  6233. * Gets or sets the width to capture in the source image
  6234. */
  6235. get: function () {
  6236. return this._sourceWidth;
  6237. },
  6238. set: function (value) {
  6239. if (this._sourceWidth === value) {
  6240. return;
  6241. }
  6242. this._sourceWidth = value;
  6243. this._markAsDirty();
  6244. },
  6245. enumerable: true,
  6246. configurable: true
  6247. });
  6248. Object.defineProperty(Image.prototype, "sourceHeight", {
  6249. /**
  6250. * Gets or sets the height to capture in the source image
  6251. */
  6252. get: function () {
  6253. return this._sourceHeight;
  6254. },
  6255. set: function (value) {
  6256. if (this._sourceHeight === value) {
  6257. return;
  6258. }
  6259. this._sourceHeight = value;
  6260. this._markAsDirty();
  6261. },
  6262. enumerable: true,
  6263. configurable: true
  6264. });
  6265. Object.defineProperty(Image.prototype, "autoScale", {
  6266. /**
  6267. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6268. * @see http://doc.babylonjs.com/how_to/gui#image
  6269. */
  6270. get: function () {
  6271. return this._autoScale;
  6272. },
  6273. set: function (value) {
  6274. if (this._autoScale === value) {
  6275. return;
  6276. }
  6277. this._autoScale = value;
  6278. if (value && this._loaded) {
  6279. this.synchronizeSizeWithContent();
  6280. }
  6281. },
  6282. enumerable: true,
  6283. configurable: true
  6284. });
  6285. Object.defineProperty(Image.prototype, "stretch", {
  6286. /** Gets or sets the streching mode used by the image */
  6287. get: function () {
  6288. return this._stretch;
  6289. },
  6290. set: function (value) {
  6291. if (this._stretch === value) {
  6292. return;
  6293. }
  6294. this._stretch = value;
  6295. this._markAsDirty();
  6296. },
  6297. enumerable: true,
  6298. configurable: true
  6299. });
  6300. Object.defineProperty(Image.prototype, "domImage", {
  6301. get: function () {
  6302. return this._domImage;
  6303. },
  6304. /**
  6305. * Gets or sets the internal DOM image used to render the control
  6306. */
  6307. set: function (value) {
  6308. var _this = this;
  6309. this._domImage = value;
  6310. this._loaded = false;
  6311. if (this._domImage.width) {
  6312. this._onImageLoaded();
  6313. }
  6314. else {
  6315. this._domImage.onload = function () {
  6316. _this._onImageLoaded();
  6317. };
  6318. }
  6319. },
  6320. enumerable: true,
  6321. configurable: true
  6322. });
  6323. Image.prototype._onImageLoaded = function () {
  6324. this._imageWidth = this._domImage.width;
  6325. this._imageHeight = this._domImage.height;
  6326. this._loaded = true;
  6327. if (this._populateNinePatchSlicesFromImage) {
  6328. this._extractNinePatchSliceDataFromImage();
  6329. }
  6330. if (this._autoScale) {
  6331. this.synchronizeSizeWithContent();
  6332. }
  6333. this.onImageLoadedObservable.notifyObservers(this);
  6334. this._markAsDirty();
  6335. };
  6336. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6337. if (!Image._WorkingCanvas) {
  6338. Image._WorkingCanvas = document.createElement('canvas');
  6339. }
  6340. var canvas = Image._WorkingCanvas;
  6341. var context = canvas.getContext('2d');
  6342. var width = this._domImage.width;
  6343. var height = this._domImage.height;
  6344. canvas.width = width;
  6345. canvas.height = height;
  6346. context.drawImage(this._domImage, 0, 0, width, height);
  6347. var imageData = context.getImageData(0, 0, width, height);
  6348. // Left and right
  6349. this._sliceLeft = -1;
  6350. this._sliceRight = -1;
  6351. for (var x = 0; x < width; x++) {
  6352. var alpha = imageData.data[x * 4 + 3];
  6353. if (alpha > 127 && this._sliceLeft === -1) {
  6354. this._sliceLeft = x;
  6355. continue;
  6356. }
  6357. if (alpha < 127 && this._sliceLeft > -1) {
  6358. this._sliceRight = x;
  6359. break;
  6360. }
  6361. }
  6362. // top and bottom
  6363. this._sliceTop = -1;
  6364. this._sliceBottom = -1;
  6365. for (var y = 0; y < height; y++) {
  6366. var alpha = imageData.data[y * width * 4 + 3];
  6367. if (alpha > 127 && this._sliceTop === -1) {
  6368. this._sliceTop = y;
  6369. continue;
  6370. }
  6371. if (alpha < 127 && this._sliceTop > -1) {
  6372. this._sliceBottom = y;
  6373. break;
  6374. }
  6375. }
  6376. };
  6377. Object.defineProperty(Image.prototype, "source", {
  6378. /**
  6379. * Gets or sets image source url
  6380. */
  6381. set: function (value) {
  6382. var _this = this;
  6383. if (this._source === value) {
  6384. return;
  6385. }
  6386. this._loaded = false;
  6387. this._source = value;
  6388. this._domImage = document.createElement("img");
  6389. this._domImage.onload = function () {
  6390. _this._onImageLoaded();
  6391. };
  6392. if (value) {
  6393. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6394. this._domImage.src = value;
  6395. }
  6396. },
  6397. enumerable: true,
  6398. configurable: true
  6399. });
  6400. Object.defineProperty(Image.prototype, "cellWidth", {
  6401. /**
  6402. * Gets or sets the cell width to use when animation sheet is enabled
  6403. * @see http://doc.babylonjs.com/how_to/gui#image
  6404. */
  6405. get: function () {
  6406. return this._cellWidth;
  6407. },
  6408. set: function (value) {
  6409. if (this._cellWidth === value) {
  6410. return;
  6411. }
  6412. this._cellWidth = value;
  6413. this._markAsDirty();
  6414. },
  6415. enumerable: true,
  6416. configurable: true
  6417. });
  6418. Object.defineProperty(Image.prototype, "cellHeight", {
  6419. /**
  6420. * Gets or sets the cell height to use when animation sheet is enabled
  6421. * @see http://doc.babylonjs.com/how_to/gui#image
  6422. */
  6423. get: function () {
  6424. return this._cellHeight;
  6425. },
  6426. set: function (value) {
  6427. if (this._cellHeight === value) {
  6428. return;
  6429. }
  6430. this._cellHeight = value;
  6431. this._markAsDirty();
  6432. },
  6433. enumerable: true,
  6434. configurable: true
  6435. });
  6436. Object.defineProperty(Image.prototype, "cellId", {
  6437. /**
  6438. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6439. * @see http://doc.babylonjs.com/how_to/gui#image
  6440. */
  6441. get: function () {
  6442. return this._cellId;
  6443. },
  6444. set: function (value) {
  6445. if (this._cellId === value) {
  6446. return;
  6447. }
  6448. this._cellId = value;
  6449. this._markAsDirty();
  6450. },
  6451. enumerable: true,
  6452. configurable: true
  6453. });
  6454. /**
  6455. * Tests if a given coordinates belong to the current control
  6456. * @param x defines x coordinate to test
  6457. * @param y defines y coordinate to test
  6458. * @returns true if the coordinates are inside the control
  6459. */
  6460. Image.prototype.contains = function (x, y) {
  6461. if (!_super.prototype.contains.call(this, x, y)) {
  6462. return false;
  6463. }
  6464. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6465. return true;
  6466. }
  6467. var canvas = Image._WorkingCanvas;
  6468. var context = canvas.getContext("2d");
  6469. var width = this._currentMeasure.width | 0;
  6470. var height = this._currentMeasure.height | 0;
  6471. var imageData = context.getImageData(0, 0, width, height).data;
  6472. x = (x - this._currentMeasure.left) | 0;
  6473. y = (y - this._currentMeasure.top) | 0;
  6474. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6475. return pickedPixel > 0;
  6476. };
  6477. Image.prototype._getTypeName = function () {
  6478. return "Image";
  6479. };
  6480. /** Force the control to synchronize with its content */
  6481. Image.prototype.synchronizeSizeWithContent = function () {
  6482. if (!this._loaded) {
  6483. return;
  6484. }
  6485. this.width = this._domImage.width + "px";
  6486. this.height = this._domImage.height + "px";
  6487. };
  6488. Image.prototype._processMeasures = function (parentMeasure, context) {
  6489. if (this._loaded) {
  6490. switch (this._stretch) {
  6491. case Image.STRETCH_NONE:
  6492. break;
  6493. case Image.STRETCH_FILL:
  6494. break;
  6495. case Image.STRETCH_UNIFORM:
  6496. break;
  6497. case Image.STRETCH_NINE_PATCH:
  6498. break;
  6499. case Image.STRETCH_EXTEND:
  6500. if (this._autoScale) {
  6501. this.synchronizeSizeWithContent();
  6502. }
  6503. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6504. this.parent.adaptWidthToChildren = true;
  6505. this.parent.adaptHeightToChildren = true;
  6506. }
  6507. break;
  6508. }
  6509. }
  6510. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6511. };
  6512. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6513. if (!this._detectPointerOnOpaqueOnly) {
  6514. return;
  6515. }
  6516. if (!Image._WorkingCanvas) {
  6517. Image._WorkingCanvas = document.createElement('canvas');
  6518. }
  6519. var canvas = Image._WorkingCanvas;
  6520. var width = this._currentMeasure.width;
  6521. var height = this._currentMeasure.height;
  6522. var context = canvas.getContext("2d");
  6523. canvas.width = width;
  6524. canvas.height = height;
  6525. context.clearRect(0, 0, width, height);
  6526. };
  6527. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6528. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6529. if (!this._detectPointerOnOpaqueOnly) {
  6530. return;
  6531. }
  6532. var canvas = Image._WorkingCanvas;
  6533. context = canvas.getContext("2d");
  6534. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6535. };
  6536. Image.prototype._draw = function (context) {
  6537. context.save();
  6538. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6539. context.shadowColor = this.shadowColor;
  6540. context.shadowBlur = this.shadowBlur;
  6541. context.shadowOffsetX = this.shadowOffsetX;
  6542. context.shadowOffsetY = this.shadowOffsetY;
  6543. }
  6544. var x, y, width, height;
  6545. if (this.cellId == -1) {
  6546. x = this._sourceLeft;
  6547. y = this._sourceTop;
  6548. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6549. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6550. }
  6551. else {
  6552. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6553. var column = (this.cellId / rowCount) >> 0;
  6554. var row = this.cellId % rowCount;
  6555. x = this.cellWidth * row;
  6556. y = this.cellHeight * column;
  6557. width = this.cellWidth;
  6558. height = this.cellHeight;
  6559. }
  6560. this._prepareWorkingCanvasForOpaqueDetection();
  6561. this._applyStates(context);
  6562. if (this._loaded) {
  6563. switch (this._stretch) {
  6564. case Image.STRETCH_NONE:
  6565. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6566. break;
  6567. case Image.STRETCH_FILL:
  6568. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6569. break;
  6570. case Image.STRETCH_UNIFORM:
  6571. var hRatio = this._currentMeasure.width / width;
  6572. var vRatio = this._currentMeasure.height / height;
  6573. var ratio = Math.min(hRatio, vRatio);
  6574. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6575. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6576. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6577. break;
  6578. case Image.STRETCH_EXTEND:
  6579. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6580. break;
  6581. case Image.STRETCH_NINE_PATCH:
  6582. this._renderNinePatch(context);
  6583. break;
  6584. }
  6585. }
  6586. context.restore();
  6587. };
  6588. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6589. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6590. };
  6591. Image.prototype._renderNinePatch = function (context) {
  6592. var height = this._imageHeight;
  6593. var leftWidth = this._sliceLeft;
  6594. var topHeight = this._sliceTop;
  6595. var bottomHeight = this._imageHeight - this._sliceBottom;
  6596. var rightWidth = this._imageWidth - this._sliceRight;
  6597. var left = 0;
  6598. var top = 0;
  6599. if (this._populateNinePatchSlicesFromImage) {
  6600. left = 1;
  6601. top = 1;
  6602. height -= 2;
  6603. leftWidth -= 1;
  6604. topHeight -= 1;
  6605. bottomHeight -= 1;
  6606. rightWidth -= 1;
  6607. }
  6608. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6609. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6610. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6611. // Corners
  6612. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6613. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6614. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6615. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6616. // Center
  6617. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop + 1, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight + 1);
  6618. // Borders
  6619. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6620. this._drawImage(context, this._sliceRight, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + this._currentMeasure.width - rightWidth, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6621. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6622. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6623. };
  6624. Image.prototype.dispose = function () {
  6625. _super.prototype.dispose.call(this);
  6626. this.onImageLoadedObservable.clear();
  6627. };
  6628. Image._WorkingCanvas = null;
  6629. // Static
  6630. /** STRETCH_NONE */
  6631. Image.STRETCH_NONE = 0;
  6632. /** STRETCH_FILL */
  6633. Image.STRETCH_FILL = 1;
  6634. /** STRETCH_UNIFORM */
  6635. Image.STRETCH_UNIFORM = 2;
  6636. /** STRETCH_EXTEND */
  6637. Image.STRETCH_EXTEND = 3;
  6638. /** NINE_PATCH */
  6639. Image.STRETCH_NINE_PATCH = 4;
  6640. return Image;
  6641. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6642. /***/ }),
  6643. /***/ "./2D/controls/index.ts":
  6644. /*!******************************!*\
  6645. !*** ./2D/controls/index.ts ***!
  6646. \******************************/
  6647. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, name */
  6648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6649. "use strict";
  6650. __webpack_require__.r(__webpack_exports__);
  6651. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6653. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6655. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6657. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6659. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6661. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6663. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6665. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6667. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6669. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6671. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6673. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6675. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6677. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6679. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6685. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6687. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6690. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6693. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6695. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6697. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6699. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6701. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6703. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_23__["name"]; });
  6705. /***/ }),
  6706. /***/ "./2D/controls/inputPassword.ts":
  6707. /*!**************************************!*\
  6708. !*** ./2D/controls/inputPassword.ts ***!
  6709. \**************************************/
  6710. /*! exports provided: InputPassword */
  6711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6712. "use strict";
  6713. __webpack_require__.r(__webpack_exports__);
  6714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6715. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6716. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6717. /**
  6718. * Class used to create a password control
  6719. */
  6720. var InputPassword = /** @class */ (function (_super) {
  6721. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6722. function InputPassword() {
  6723. return _super !== null && _super.apply(this, arguments) || this;
  6724. }
  6725. InputPassword.prototype._beforeRenderText = function (text) {
  6726. var txt = "";
  6727. for (var i = 0; i < text.length; i++) {
  6728. txt += "\u2022";
  6729. }
  6730. return txt;
  6731. };
  6732. return InputPassword;
  6733. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6734. /***/ }),
  6735. /***/ "./2D/controls/inputText.ts":
  6736. /*!**********************************!*\
  6737. !*** ./2D/controls/inputText.ts ***!
  6738. \**********************************/
  6739. /*! exports provided: InputText */
  6740. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6741. "use strict";
  6742. __webpack_require__.r(__webpack_exports__);
  6743. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6744. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6745. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6746. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6747. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6748. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6749. /**
  6750. * Class used to create input text control
  6751. */
  6752. var InputText = /** @class */ (function (_super) {
  6753. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6754. /**
  6755. * Creates a new InputText
  6756. * @param name defines the control name
  6757. * @param text defines the text of the control
  6758. */
  6759. function InputText(name, text) {
  6760. if (text === void 0) { text = ""; }
  6761. var _this = _super.call(this, name) || this;
  6762. _this.name = name;
  6763. _this._text = "";
  6764. _this._placeholderText = "";
  6765. _this._background = "#222222";
  6766. _this._focusedBackground = "#000000";
  6767. _this._focusedColor = "white";
  6768. _this._placeholderColor = "gray";
  6769. _this._thickness = 1;
  6770. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6771. _this._autoStretchWidth = true;
  6772. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6773. _this._isFocused = false;
  6774. _this._blinkIsEven = false;
  6775. _this._cursorOffset = 0;
  6776. _this._deadKey = false;
  6777. _this._addKey = true;
  6778. _this._currentKey = "";
  6779. _this._isTextHighlightOn = false;
  6780. _this._textHighlightColor = "#d5e0ff";
  6781. _this._highligherOpacity = 0.4;
  6782. _this._highlightedText = "";
  6783. _this._startHighlightIndex = 0;
  6784. _this._endHighlightIndex = 0;
  6785. _this._cursorIndex = -1;
  6786. _this._onFocusSelectAll = false;
  6787. _this._isPointerDown = false;
  6788. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6789. _this.promptMessage = "Please enter text:";
  6790. /** Observable raised when the text changes */
  6791. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6792. /** Observable raised just before an entered character is to be added */
  6793. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6794. /** Observable raised when the control gets the focus */
  6795. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6796. /** Observable raised when the control loses the focus */
  6797. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6798. /**Observable raised when the text is highlighted */
  6799. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6800. /**Observable raised when copy event is triggered */
  6801. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6802. /** Observable raised when cut event is triggered */
  6803. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6804. /** Observable raised when paste event is triggered */
  6805. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6806. /** Observable raised when a key event was processed */
  6807. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6808. _this.text = text;
  6809. _this.isPointerBlocker = true;
  6810. return _this;
  6811. }
  6812. Object.defineProperty(InputText.prototype, "maxWidth", {
  6813. /** Gets or sets the maximum width allowed by the control */
  6814. get: function () {
  6815. return this._maxWidth.toString(this._host);
  6816. },
  6817. set: function (value) {
  6818. if (this._maxWidth.toString(this._host) === value) {
  6819. return;
  6820. }
  6821. if (this._maxWidth.fromString(value)) {
  6822. this._markAsDirty();
  6823. }
  6824. },
  6825. enumerable: true,
  6826. configurable: true
  6827. });
  6828. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6829. /** Gets the maximum width allowed by the control in pixels */
  6830. get: function () {
  6831. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6832. },
  6833. enumerable: true,
  6834. configurable: true
  6835. });
  6836. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6837. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6838. get: function () {
  6839. return this._highligherOpacity;
  6840. },
  6841. set: function (value) {
  6842. if (this._highligherOpacity === value) {
  6843. return;
  6844. }
  6845. this._highligherOpacity = value;
  6846. this._markAsDirty();
  6847. },
  6848. enumerable: true,
  6849. configurable: true
  6850. });
  6851. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6852. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6853. get: function () {
  6854. return this._onFocusSelectAll;
  6855. },
  6856. set: function (value) {
  6857. if (this._onFocusSelectAll === value) {
  6858. return;
  6859. }
  6860. this._onFocusSelectAll = value;
  6861. this._markAsDirty();
  6862. },
  6863. enumerable: true,
  6864. configurable: true
  6865. });
  6866. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6867. /** Gets or sets the text hightlight color */
  6868. get: function () {
  6869. return this._textHighlightColor;
  6870. },
  6871. set: function (value) {
  6872. if (this._textHighlightColor === value) {
  6873. return;
  6874. }
  6875. this._textHighlightColor = value;
  6876. this._markAsDirty();
  6877. },
  6878. enumerable: true,
  6879. configurable: true
  6880. });
  6881. Object.defineProperty(InputText.prototype, "margin", {
  6882. /** Gets or sets control margin */
  6883. get: function () {
  6884. return this._margin.toString(this._host);
  6885. },
  6886. set: function (value) {
  6887. if (this._margin.toString(this._host) === value) {
  6888. return;
  6889. }
  6890. if (this._margin.fromString(value)) {
  6891. this._markAsDirty();
  6892. }
  6893. },
  6894. enumerable: true,
  6895. configurable: true
  6896. });
  6897. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6898. /** Gets control margin in pixels */
  6899. get: function () {
  6900. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6901. },
  6902. enumerable: true,
  6903. configurable: true
  6904. });
  6905. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6906. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6907. get: function () {
  6908. return this._autoStretchWidth;
  6909. },
  6910. set: function (value) {
  6911. if (this._autoStretchWidth === value) {
  6912. return;
  6913. }
  6914. this._autoStretchWidth = value;
  6915. this._markAsDirty();
  6916. },
  6917. enumerable: true,
  6918. configurable: true
  6919. });
  6920. Object.defineProperty(InputText.prototype, "thickness", {
  6921. /** Gets or sets border thickness */
  6922. get: function () {
  6923. return this._thickness;
  6924. },
  6925. set: function (value) {
  6926. if (this._thickness === value) {
  6927. return;
  6928. }
  6929. this._thickness = value;
  6930. this._markAsDirty();
  6931. },
  6932. enumerable: true,
  6933. configurable: true
  6934. });
  6935. Object.defineProperty(InputText.prototype, "focusedBackground", {
  6936. /** Gets or sets the background color when focused */
  6937. get: function () {
  6938. return this._focusedBackground;
  6939. },
  6940. set: function (value) {
  6941. if (this._focusedBackground === value) {
  6942. return;
  6943. }
  6944. this._focusedBackground = value;
  6945. this._markAsDirty();
  6946. },
  6947. enumerable: true,
  6948. configurable: true
  6949. });
  6950. Object.defineProperty(InputText.prototype, "focusedColor", {
  6951. /** Gets or sets the background color when focused */
  6952. get: function () {
  6953. return this._focusedColor;
  6954. },
  6955. set: function (value) {
  6956. if (this._focusedColor === value) {
  6957. return;
  6958. }
  6959. this._focusedColor = value;
  6960. this._markAsDirty();
  6961. },
  6962. enumerable: true,
  6963. configurable: true
  6964. });
  6965. Object.defineProperty(InputText.prototype, "background", {
  6966. /** Gets or sets the background color */
  6967. get: function () {
  6968. return this._background;
  6969. },
  6970. set: function (value) {
  6971. if (this._background === value) {
  6972. return;
  6973. }
  6974. this._background = value;
  6975. this._markAsDirty();
  6976. },
  6977. enumerable: true,
  6978. configurable: true
  6979. });
  6980. Object.defineProperty(InputText.prototype, "placeholderColor", {
  6981. /** Gets or sets the placeholder color */
  6982. get: function () {
  6983. return this._placeholderColor;
  6984. },
  6985. set: function (value) {
  6986. if (this._placeholderColor === value) {
  6987. return;
  6988. }
  6989. this._placeholderColor = value;
  6990. this._markAsDirty();
  6991. },
  6992. enumerable: true,
  6993. configurable: true
  6994. });
  6995. Object.defineProperty(InputText.prototype, "placeholderText", {
  6996. /** Gets or sets the text displayed when the control is empty */
  6997. get: function () {
  6998. return this._placeholderText;
  6999. },
  7000. set: function (value) {
  7001. if (this._placeholderText === value) {
  7002. return;
  7003. }
  7004. this._placeholderText = value;
  7005. this._markAsDirty();
  7006. },
  7007. enumerable: true,
  7008. configurable: true
  7009. });
  7010. Object.defineProperty(InputText.prototype, "deadKey", {
  7011. /** Gets or sets the dead key flag */
  7012. get: function () {
  7013. return this._deadKey;
  7014. },
  7015. set: function (flag) {
  7016. this._deadKey = flag;
  7017. },
  7018. enumerable: true,
  7019. configurable: true
  7020. });
  7021. Object.defineProperty(InputText.prototype, "highlightedText", {
  7022. /** Gets or sets the highlight text */
  7023. get: function () {
  7024. return this._highlightedText;
  7025. },
  7026. set: function (text) {
  7027. if (this._highlightedText === text) {
  7028. return;
  7029. }
  7030. this._highlightedText = text;
  7031. this._markAsDirty();
  7032. },
  7033. enumerable: true,
  7034. configurable: true
  7035. });
  7036. Object.defineProperty(InputText.prototype, "addKey", {
  7037. /** Gets or sets if the current key should be added */
  7038. get: function () {
  7039. return this._addKey;
  7040. },
  7041. set: function (flag) {
  7042. this._addKey = flag;
  7043. },
  7044. enumerable: true,
  7045. configurable: true
  7046. });
  7047. Object.defineProperty(InputText.prototype, "currentKey", {
  7048. /** Gets or sets the value of the current key being entered */
  7049. get: function () {
  7050. return this._currentKey;
  7051. },
  7052. set: function (key) {
  7053. this._currentKey = key;
  7054. },
  7055. enumerable: true,
  7056. configurable: true
  7057. });
  7058. Object.defineProperty(InputText.prototype, "text", {
  7059. /** Gets or sets the text displayed in the control */
  7060. get: function () {
  7061. return this._text;
  7062. },
  7063. set: function (value) {
  7064. var valueAsString = value.toString(); // Forcing convertion
  7065. if (this._text === valueAsString) {
  7066. return;
  7067. }
  7068. this._text = valueAsString;
  7069. this._markAsDirty();
  7070. this.onTextChangedObservable.notifyObservers(this);
  7071. },
  7072. enumerable: true,
  7073. configurable: true
  7074. });
  7075. Object.defineProperty(InputText.prototype, "width", {
  7076. /** Gets or sets control width */
  7077. get: function () {
  7078. return this._width.toString(this._host);
  7079. },
  7080. set: function (value) {
  7081. if (this._width.toString(this._host) === value) {
  7082. return;
  7083. }
  7084. if (this._width.fromString(value)) {
  7085. this._markAsDirty();
  7086. }
  7087. this.autoStretchWidth = false;
  7088. },
  7089. enumerable: true,
  7090. configurable: true
  7091. });
  7092. /** @hidden */
  7093. InputText.prototype.onBlur = function () {
  7094. this._isFocused = false;
  7095. this._scrollLeft = null;
  7096. this._cursorOffset = 0;
  7097. clearTimeout(this._blinkTimeout);
  7098. this._markAsDirty();
  7099. this.onBlurObservable.notifyObservers(this);
  7100. this._host.unRegisterClipboardEvents();
  7101. if (this._onClipboardObserver) {
  7102. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7103. }
  7104. var scene = this._host.getScene();
  7105. if (this._onPointerDblTapObserver && scene) {
  7106. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7107. }
  7108. };
  7109. /** @hidden */
  7110. InputText.prototype.onFocus = function () {
  7111. var _this = this;
  7112. if (!this._isEnabled) {
  7113. return;
  7114. }
  7115. this._scrollLeft = null;
  7116. this._isFocused = true;
  7117. this._blinkIsEven = false;
  7118. this._cursorOffset = 0;
  7119. this._markAsDirty();
  7120. this.onFocusObservable.notifyObservers(this);
  7121. if (navigator.userAgent.indexOf("Mobile") !== -1) {
  7122. var value = prompt(this.promptMessage);
  7123. if (value !== null) {
  7124. this.text = value;
  7125. }
  7126. this._host.focusedControl = null;
  7127. return;
  7128. }
  7129. this._host.registerClipboardEvents();
  7130. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7131. // process clipboard event, can be configured.
  7132. switch (clipboardInfo.type) {
  7133. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7134. _this._onCopyText(clipboardInfo.event);
  7135. _this.onTextCopyObservable.notifyObservers(_this);
  7136. break;
  7137. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7138. _this._onCutText(clipboardInfo.event);
  7139. _this.onTextCutObservable.notifyObservers(_this);
  7140. break;
  7141. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7142. _this._onPasteText(clipboardInfo.event);
  7143. _this.onTextPasteObservable.notifyObservers(_this);
  7144. break;
  7145. default: return;
  7146. }
  7147. });
  7148. var scene = this._host.getScene();
  7149. if (scene) {
  7150. //register the pointer double tap event
  7151. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7152. if (!_this._isFocused) {
  7153. return;
  7154. }
  7155. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7156. _this._processDblClick(pointerInfo);
  7157. }
  7158. });
  7159. }
  7160. if (this._onFocusSelectAll) {
  7161. this._selectAllText();
  7162. }
  7163. };
  7164. InputText.prototype._getTypeName = function () {
  7165. return "InputText";
  7166. };
  7167. /**
  7168. * Function called to get the list of controls that should not steal the focus from this control
  7169. * @returns an array of controls
  7170. */
  7171. InputText.prototype.keepsFocusWith = function () {
  7172. if (!this._connectedVirtualKeyboard) {
  7173. return null;
  7174. }
  7175. return [this._connectedVirtualKeyboard];
  7176. };
  7177. /** @hidden */
  7178. InputText.prototype.processKey = function (keyCode, key, evt) {
  7179. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7180. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7181. return;
  7182. }
  7183. //select all
  7184. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7185. this._selectAllText();
  7186. evt.preventDefault();
  7187. return;
  7188. }
  7189. // Specific cases
  7190. switch (keyCode) {
  7191. case 32: //SPACE
  7192. key = " "; //ie11 key for space is "Spacebar"
  7193. break;
  7194. case 191: //SLASH
  7195. if (evt) {
  7196. evt.preventDefault();
  7197. }
  7198. break;
  7199. case 8: // BACKSPACE
  7200. if (this._text && this._text.length > 0) {
  7201. //delete the highlighted text
  7202. if (this._isTextHighlightOn) {
  7203. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7204. this._isTextHighlightOn = false;
  7205. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7206. this._blinkIsEven = false;
  7207. if (evt) {
  7208. evt.preventDefault();
  7209. }
  7210. return;
  7211. }
  7212. //delete single character
  7213. if (this._cursorOffset === 0) {
  7214. this.text = this._text.substr(0, this._text.length - 1);
  7215. }
  7216. else {
  7217. var deletePosition = this._text.length - this._cursorOffset;
  7218. if (deletePosition > 0) {
  7219. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7220. }
  7221. }
  7222. }
  7223. if (evt) {
  7224. evt.preventDefault();
  7225. }
  7226. return;
  7227. case 46: // DELETE
  7228. if (this._isTextHighlightOn) {
  7229. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7230. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7231. while (decrementor > 0 && this._cursorOffset > 0) {
  7232. this._cursorOffset--;
  7233. }
  7234. this._isTextHighlightOn = false;
  7235. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7236. if (evt) {
  7237. evt.preventDefault();
  7238. }
  7239. return;
  7240. }
  7241. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7242. var deletePosition = this._text.length - this._cursorOffset;
  7243. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7244. this._cursorOffset--;
  7245. }
  7246. if (evt) {
  7247. evt.preventDefault();
  7248. }
  7249. return;
  7250. case 13: // RETURN
  7251. this._host.focusedControl = null;
  7252. this._isTextHighlightOn = false;
  7253. return;
  7254. case 35: // END
  7255. this._cursorOffset = 0;
  7256. this._blinkIsEven = false;
  7257. this._isTextHighlightOn = false;
  7258. this._markAsDirty();
  7259. return;
  7260. case 36: // HOME
  7261. this._cursorOffset = this._text.length;
  7262. this._blinkIsEven = false;
  7263. this._isTextHighlightOn = false;
  7264. this._markAsDirty();
  7265. return;
  7266. case 37: // LEFT
  7267. this._cursorOffset++;
  7268. if (this._cursorOffset > this._text.length) {
  7269. this._cursorOffset = this._text.length;
  7270. }
  7271. if (evt && evt.shiftKey) {
  7272. // update the cursor
  7273. this._blinkIsEven = false;
  7274. // shift + ctrl/cmd + <-
  7275. if (evt.ctrlKey || evt.metaKey) {
  7276. if (!this._isTextHighlightOn) {
  7277. if (this._text.length === this._cursorOffset) {
  7278. return;
  7279. }
  7280. else {
  7281. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7282. }
  7283. }
  7284. this._startHighlightIndex = 0;
  7285. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7286. this._cursorOffset = this._text.length;
  7287. this._isTextHighlightOn = true;
  7288. this._markAsDirty();
  7289. return;
  7290. }
  7291. //store the starting point
  7292. if (!this._isTextHighlightOn) {
  7293. this._isTextHighlightOn = true;
  7294. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7295. }
  7296. //if text is already highlighted
  7297. else if (this._cursorIndex === -1) {
  7298. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7299. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7300. }
  7301. //set the highlight indexes
  7302. if (this._cursorIndex < this._cursorOffset) {
  7303. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7304. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7305. }
  7306. else if (this._cursorIndex > this._cursorOffset) {
  7307. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7308. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7309. }
  7310. else {
  7311. this._isTextHighlightOn = false;
  7312. }
  7313. this._markAsDirty();
  7314. return;
  7315. }
  7316. if (this._isTextHighlightOn) {
  7317. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7318. this._isTextHighlightOn = false;
  7319. }
  7320. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7321. this._cursorOffset = this.text.length;
  7322. evt.preventDefault();
  7323. }
  7324. this._blinkIsEven = false;
  7325. this._isTextHighlightOn = false;
  7326. this._cursorIndex = -1;
  7327. this._markAsDirty();
  7328. return;
  7329. case 39: // RIGHT
  7330. this._cursorOffset--;
  7331. if (this._cursorOffset < 0) {
  7332. this._cursorOffset = 0;
  7333. }
  7334. if (evt && evt.shiftKey) {
  7335. //update the cursor
  7336. this._blinkIsEven = false;
  7337. //shift + ctrl/cmd + ->
  7338. if (evt.ctrlKey || evt.metaKey) {
  7339. if (!this._isTextHighlightOn) {
  7340. if (this._cursorOffset === 0) {
  7341. return;
  7342. }
  7343. else {
  7344. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7345. }
  7346. }
  7347. this._endHighlightIndex = this._text.length;
  7348. this._isTextHighlightOn = true;
  7349. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7350. this._cursorOffset = 0;
  7351. this._markAsDirty();
  7352. return;
  7353. }
  7354. if (!this._isTextHighlightOn) {
  7355. this._isTextHighlightOn = true;
  7356. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7357. }
  7358. //if text is already highlighted
  7359. else if (this._cursorIndex === -1) {
  7360. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7361. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7362. }
  7363. //set the highlight indexes
  7364. if (this._cursorIndex < this._cursorOffset) {
  7365. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7366. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7367. }
  7368. else if (this._cursorIndex > this._cursorOffset) {
  7369. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7370. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7371. }
  7372. else {
  7373. this._isTextHighlightOn = false;
  7374. }
  7375. this._markAsDirty();
  7376. return;
  7377. }
  7378. if (this._isTextHighlightOn) {
  7379. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7380. this._isTextHighlightOn = false;
  7381. }
  7382. //ctr + ->
  7383. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7384. this._cursorOffset = 0;
  7385. evt.preventDefault();
  7386. }
  7387. this._blinkIsEven = false;
  7388. this._isTextHighlightOn = false;
  7389. this._cursorIndex = -1;
  7390. this._markAsDirty();
  7391. return;
  7392. case 222: // Dead
  7393. if (evt) {
  7394. evt.preventDefault();
  7395. }
  7396. this._cursorIndex = -1;
  7397. this.deadKey = true;
  7398. break;
  7399. }
  7400. // Printable characters
  7401. if (key &&
  7402. ((keyCode === -1) || // Direct access
  7403. (keyCode === 32) || // Space
  7404. (keyCode > 47 && keyCode < 64) || // Numbers
  7405. (keyCode > 64 && keyCode < 91) || // Letters
  7406. (keyCode > 159 && keyCode < 193) || // Special characters
  7407. (keyCode > 218 && keyCode < 223) || // Special characters
  7408. (keyCode > 95 && keyCode < 112))) { // Numpad
  7409. this._currentKey = key;
  7410. this.onBeforeKeyAddObservable.notifyObservers(this);
  7411. key = this._currentKey;
  7412. if (this._addKey) {
  7413. if (this._isTextHighlightOn) {
  7414. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7415. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7416. this._isTextHighlightOn = false;
  7417. this._blinkIsEven = false;
  7418. this._markAsDirty();
  7419. }
  7420. else if (this._cursorOffset === 0) {
  7421. this.text += key;
  7422. }
  7423. else {
  7424. var insertPosition = this._text.length - this._cursorOffset;
  7425. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7426. }
  7427. }
  7428. }
  7429. };
  7430. /** @hidden */
  7431. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7432. //update the cursor
  7433. this._blinkIsEven = false;
  7434. if (this._cursorIndex === -1) {
  7435. this._cursorIndex = offset;
  7436. }
  7437. else {
  7438. if (this._cursorIndex < this._cursorOffset) {
  7439. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7440. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7441. }
  7442. else if (this._cursorIndex > this._cursorOffset) {
  7443. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7444. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7445. }
  7446. else {
  7447. this._isTextHighlightOn = false;
  7448. this._markAsDirty();
  7449. return;
  7450. }
  7451. }
  7452. this._isTextHighlightOn = true;
  7453. this._markAsDirty();
  7454. };
  7455. /** @hidden */
  7456. InputText.prototype._processDblClick = function (evt) {
  7457. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7458. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7459. this._endHighlightIndex = this._startHighlightIndex;
  7460. var rWord = /\w+/g, moveLeft, moveRight;
  7461. do {
  7462. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7463. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7464. } while (moveLeft || moveRight);
  7465. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7466. this.onTextHighlightObservable.notifyObservers(this);
  7467. this._isTextHighlightOn = true;
  7468. this._clickedCoordinate = null;
  7469. this._blinkIsEven = true;
  7470. this._cursorIndex = -1;
  7471. this._markAsDirty();
  7472. };
  7473. /** @hidden */
  7474. InputText.prototype._selectAllText = function () {
  7475. this._blinkIsEven = true;
  7476. this._isTextHighlightOn = true;
  7477. this._startHighlightIndex = 0;
  7478. this._endHighlightIndex = this._text.length;
  7479. this._cursorOffset = this._text.length;
  7480. this._cursorIndex = -1;
  7481. this._markAsDirty();
  7482. };
  7483. /**
  7484. * Handles the keyboard event
  7485. * @param evt Defines the KeyboardEvent
  7486. */
  7487. InputText.prototype.processKeyboard = function (evt) {
  7488. // process pressed key
  7489. this.processKey(evt.keyCode, evt.key, evt);
  7490. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7491. };
  7492. /** @hidden */
  7493. InputText.prototype._onCopyText = function (ev) {
  7494. this._isTextHighlightOn = false;
  7495. //when write permission to clipbaord data is denied
  7496. try {
  7497. ev.clipboardData.setData("text/plain", this._highlightedText);
  7498. }
  7499. catch (_a) { } //pass
  7500. this._host.clipboardData = this._highlightedText;
  7501. };
  7502. /** @hidden */
  7503. InputText.prototype._onCutText = function (ev) {
  7504. if (!this._highlightedText) {
  7505. return;
  7506. }
  7507. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7508. this._isTextHighlightOn = false;
  7509. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7510. //when write permission to clipbaord data is denied
  7511. try {
  7512. ev.clipboardData.setData("text/plain", this._highlightedText);
  7513. }
  7514. catch (_a) { } //pass
  7515. this._host.clipboardData = this._highlightedText;
  7516. this._highlightedText = "";
  7517. };
  7518. /** @hidden */
  7519. InputText.prototype._onPasteText = function (ev) {
  7520. var data = "";
  7521. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7522. data = ev.clipboardData.getData("text/plain");
  7523. }
  7524. else {
  7525. //get the cached data; returns blank string by default
  7526. data = this._host.clipboardData;
  7527. }
  7528. var insertPosition = this._text.length - this._cursorOffset;
  7529. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7530. };
  7531. InputText.prototype._draw = function (context) {
  7532. var _this = this;
  7533. context.save();
  7534. this._applyStates(context);
  7535. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7536. context.shadowColor = this.shadowColor;
  7537. context.shadowBlur = this.shadowBlur;
  7538. context.shadowOffsetX = this.shadowOffsetX;
  7539. context.shadowOffsetY = this.shadowOffsetY;
  7540. }
  7541. // Background
  7542. if (this._isFocused) {
  7543. if (this._focusedBackground) {
  7544. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7545. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7546. }
  7547. }
  7548. else if (this._background) {
  7549. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7550. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7551. }
  7552. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7553. context.shadowBlur = 0;
  7554. context.shadowOffsetX = 0;
  7555. context.shadowOffsetY = 0;
  7556. }
  7557. if (!this._fontOffset) {
  7558. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7559. }
  7560. // Text
  7561. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7562. if (this.color) {
  7563. context.fillStyle = this.color;
  7564. }
  7565. var text = this._beforeRenderText(this._text);
  7566. if (!this._isFocused && !this._text && this._placeholderText) {
  7567. text = this._placeholderText;
  7568. if (this._placeholderColor) {
  7569. context.fillStyle = this._placeholderColor;
  7570. }
  7571. }
  7572. this._textWidth = context.measureText(text).width;
  7573. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7574. if (this._autoStretchWidth) {
  7575. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7576. }
  7577. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7578. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7579. context.save();
  7580. context.beginPath();
  7581. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7582. context.clip();
  7583. if (this._isFocused && this._textWidth > availableWidth) {
  7584. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7585. if (!this._scrollLeft) {
  7586. this._scrollLeft = textLeft;
  7587. }
  7588. }
  7589. else {
  7590. this._scrollLeft = clipTextLeft;
  7591. }
  7592. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7593. // Cursor
  7594. if (this._isFocused) {
  7595. // Need to move cursor
  7596. if (this._clickedCoordinate) {
  7597. var rightPosition = this._scrollLeft + this._textWidth;
  7598. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7599. var currentSize = 0;
  7600. this._cursorOffset = 0;
  7601. var previousDist = 0;
  7602. do {
  7603. if (this._cursorOffset) {
  7604. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7605. }
  7606. this._cursorOffset++;
  7607. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7608. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7609. // Find closest move
  7610. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7611. this._cursorOffset--;
  7612. }
  7613. this._blinkIsEven = false;
  7614. this._clickedCoordinate = null;
  7615. }
  7616. // Render cursor
  7617. if (!this._blinkIsEven) {
  7618. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7619. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7620. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7621. if (cursorLeft < clipTextLeft) {
  7622. this._scrollLeft += (clipTextLeft - cursorLeft);
  7623. cursorLeft = clipTextLeft;
  7624. this._markAsDirty();
  7625. }
  7626. else if (cursorLeft > clipTextLeft + availableWidth) {
  7627. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7628. cursorLeft = clipTextLeft + availableWidth;
  7629. this._markAsDirty();
  7630. }
  7631. if (!this._isTextHighlightOn) {
  7632. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7633. }
  7634. }
  7635. clearTimeout(this._blinkTimeout);
  7636. this._blinkTimeout = setTimeout(function () {
  7637. _this._blinkIsEven = !_this._blinkIsEven;
  7638. _this._markAsDirty();
  7639. }, 500);
  7640. //show the highlighted text
  7641. if (this._isTextHighlightOn) {
  7642. clearTimeout(this._blinkTimeout);
  7643. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7644. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7645. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7646. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7647. if (highlightCursorLeft < clipTextLeft) {
  7648. width = width - (clipTextLeft - highlightCursorLeft);
  7649. if (!width) {
  7650. // when using left arrow on text.length > availableWidth;
  7651. // assigns the width of the first letter after clipTextLeft
  7652. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7653. }
  7654. highlightCursorLeft = clipTextLeft;
  7655. }
  7656. //for transparancy
  7657. context.globalAlpha = this._highligherOpacity;
  7658. context.fillStyle = this._textHighlightColor;
  7659. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7660. context.globalAlpha = 1.0;
  7661. }
  7662. }
  7663. context.restore();
  7664. // Border
  7665. if (this._thickness) {
  7666. if (this._isFocused) {
  7667. if (this.focusedColor) {
  7668. context.strokeStyle = this.focusedColor;
  7669. }
  7670. }
  7671. else {
  7672. if (this.color) {
  7673. context.strokeStyle = this.color;
  7674. }
  7675. }
  7676. context.lineWidth = this._thickness;
  7677. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7678. }
  7679. context.restore();
  7680. };
  7681. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7682. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7683. return false;
  7684. }
  7685. this._clickedCoordinate = coordinates.x;
  7686. this._isTextHighlightOn = false;
  7687. this._highlightedText = "";
  7688. this._cursorIndex = -1;
  7689. this._isPointerDown = true;
  7690. this._host._capturingControl[pointerId] = this;
  7691. if (this._host.focusedControl === this) {
  7692. // Move cursor
  7693. clearTimeout(this._blinkTimeout);
  7694. this._markAsDirty();
  7695. return true;
  7696. }
  7697. if (!this._isEnabled) {
  7698. return false;
  7699. }
  7700. this._host.focusedControl = this;
  7701. return true;
  7702. };
  7703. InputText.prototype._onPointerMove = function (target, coordinates) {
  7704. if (this._host.focusedControl === this && this._isPointerDown) {
  7705. this._clickedCoordinate = coordinates.x;
  7706. this._markAsDirty();
  7707. this._updateValueFromCursorIndex(this._cursorOffset);
  7708. }
  7709. _super.prototype._onPointerMove.call(this, target, coordinates);
  7710. };
  7711. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7712. this._isPointerDown = false;
  7713. delete this._host._capturingControl[pointerId];
  7714. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7715. };
  7716. InputText.prototype._beforeRenderText = function (text) {
  7717. return text;
  7718. };
  7719. InputText.prototype.dispose = function () {
  7720. _super.prototype.dispose.call(this);
  7721. this.onBlurObservable.clear();
  7722. this.onFocusObservable.clear();
  7723. this.onTextChangedObservable.clear();
  7724. this.onTextCopyObservable.clear();
  7725. this.onTextCutObservable.clear();
  7726. this.onTextPasteObservable.clear();
  7727. this.onTextHighlightObservable.clear();
  7728. this.onKeyboardEventProcessedObservable.clear();
  7729. };
  7730. return InputText;
  7731. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7732. /***/ }),
  7733. /***/ "./2D/controls/line.ts":
  7734. /*!*****************************!*\
  7735. !*** ./2D/controls/line.ts ***!
  7736. \*****************************/
  7737. /*! exports provided: Line */
  7738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7739. "use strict";
  7740. __webpack_require__.r(__webpack_exports__);
  7741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7742. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7743. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  7744. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7745. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7746. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7747. /** Class used to render 2D lines */
  7748. var Line = /** @class */ (function (_super) {
  7749. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7750. /**
  7751. * Creates a new Line
  7752. * @param name defines the control name
  7753. */
  7754. function Line(name) {
  7755. var _this = _super.call(this, name) || this;
  7756. _this.name = name;
  7757. _this._lineWidth = 1;
  7758. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7759. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7760. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7761. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7762. _this._dash = new Array();
  7763. _this.isHitTestVisible = false;
  7764. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7765. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7766. return _this;
  7767. }
  7768. Object.defineProperty(Line.prototype, "dash", {
  7769. /** Gets or sets the dash pattern */
  7770. get: function () {
  7771. return this._dash;
  7772. },
  7773. set: function (value) {
  7774. if (this._dash === value) {
  7775. return;
  7776. }
  7777. this._dash = value;
  7778. this._markAsDirty();
  7779. },
  7780. enumerable: true,
  7781. configurable: true
  7782. });
  7783. Object.defineProperty(Line.prototype, "connectedControl", {
  7784. /** Gets or sets the control connected with the line end */
  7785. get: function () {
  7786. return this._connectedControl;
  7787. },
  7788. set: function (value) {
  7789. var _this = this;
  7790. if (this._connectedControl === value) {
  7791. return;
  7792. }
  7793. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7794. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7795. this._connectedControlDirtyObserver = null;
  7796. }
  7797. if (value) {
  7798. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7799. }
  7800. this._connectedControl = value;
  7801. this._markAsDirty();
  7802. },
  7803. enumerable: true,
  7804. configurable: true
  7805. });
  7806. Object.defineProperty(Line.prototype, "x1", {
  7807. /** Gets or sets start coordinates on X axis */
  7808. get: function () {
  7809. return this._x1.toString(this._host);
  7810. },
  7811. set: function (value) {
  7812. if (this._x1.toString(this._host) === value) {
  7813. return;
  7814. }
  7815. if (this._x1.fromString(value)) {
  7816. this._markAsDirty();
  7817. }
  7818. },
  7819. enumerable: true,
  7820. configurable: true
  7821. });
  7822. Object.defineProperty(Line.prototype, "y1", {
  7823. /** Gets or sets start coordinates on Y axis */
  7824. get: function () {
  7825. return this._y1.toString(this._host);
  7826. },
  7827. set: function (value) {
  7828. if (this._y1.toString(this._host) === value) {
  7829. return;
  7830. }
  7831. if (this._y1.fromString(value)) {
  7832. this._markAsDirty();
  7833. }
  7834. },
  7835. enumerable: true,
  7836. configurable: true
  7837. });
  7838. Object.defineProperty(Line.prototype, "x2", {
  7839. /** Gets or sets end coordinates on X axis */
  7840. get: function () {
  7841. return this._x2.toString(this._host);
  7842. },
  7843. set: function (value) {
  7844. if (this._x2.toString(this._host) === value) {
  7845. return;
  7846. }
  7847. if (this._x2.fromString(value)) {
  7848. this._markAsDirty();
  7849. }
  7850. },
  7851. enumerable: true,
  7852. configurable: true
  7853. });
  7854. Object.defineProperty(Line.prototype, "y2", {
  7855. /** Gets or sets end coordinates on Y axis */
  7856. get: function () {
  7857. return this._y2.toString(this._host);
  7858. },
  7859. set: function (value) {
  7860. if (this._y2.toString(this._host) === value) {
  7861. return;
  7862. }
  7863. if (this._y2.fromString(value)) {
  7864. this._markAsDirty();
  7865. }
  7866. },
  7867. enumerable: true,
  7868. configurable: true
  7869. });
  7870. Object.defineProperty(Line.prototype, "lineWidth", {
  7871. /** Gets or sets line width */
  7872. get: function () {
  7873. return this._lineWidth;
  7874. },
  7875. set: function (value) {
  7876. if (this._lineWidth === value) {
  7877. return;
  7878. }
  7879. this._lineWidth = value;
  7880. this._markAsDirty();
  7881. },
  7882. enumerable: true,
  7883. configurable: true
  7884. });
  7885. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7886. /** Gets or sets horizontal alignment */
  7887. set: function (value) {
  7888. return;
  7889. },
  7890. enumerable: true,
  7891. configurable: true
  7892. });
  7893. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7894. /** Gets or sets vertical alignment */
  7895. set: function (value) {
  7896. return;
  7897. },
  7898. enumerable: true,
  7899. configurable: true
  7900. });
  7901. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7902. get: function () {
  7903. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7904. },
  7905. enumerable: true,
  7906. configurable: true
  7907. });
  7908. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7909. get: function () {
  7910. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7911. },
  7912. enumerable: true,
  7913. configurable: true
  7914. });
  7915. Line.prototype._getTypeName = function () {
  7916. return "Line";
  7917. };
  7918. Line.prototype._draw = function (context) {
  7919. context.save();
  7920. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7921. context.shadowColor = this.shadowColor;
  7922. context.shadowBlur = this.shadowBlur;
  7923. context.shadowOffsetX = this.shadowOffsetX;
  7924. context.shadowOffsetY = this.shadowOffsetY;
  7925. }
  7926. this._applyStates(context);
  7927. context.strokeStyle = this.color;
  7928. context.lineWidth = this._lineWidth;
  7929. context.setLineDash(this._dash);
  7930. context.beginPath();
  7931. context.moveTo(this._x1.getValue(this._host), this._y1.getValue(this._host));
  7932. context.lineTo(this._effectiveX2, this._effectiveY2);
  7933. context.stroke();
  7934. context.restore();
  7935. };
  7936. Line.prototype._measure = function () {
  7937. // Width / Height
  7938. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  7939. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  7940. };
  7941. Line.prototype._computeAlignment = function (parentMeasure, context) {
  7942. this._currentMeasure.left = Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  7943. this._currentMeasure.top = Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  7944. };
  7945. /**
  7946. * Move one end of the line given 3D cartesian coordinates.
  7947. * @param position Targeted world position
  7948. * @param scene Scene
  7949. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7950. */
  7951. Line.prototype.moveToVector3 = function (position, scene, end) {
  7952. if (end === void 0) { end = false; }
  7953. if (!this._host || this.parent !== this._host._rootContainer) {
  7954. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  7955. return;
  7956. }
  7957. var globalViewport = this._host._getGlobalViewport(scene);
  7958. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  7959. this._moveToProjectedPosition(projectedPosition, end);
  7960. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  7961. this.notRenderable = true;
  7962. return;
  7963. }
  7964. this.notRenderable = false;
  7965. };
  7966. /**
  7967. * Move one end of the line to a position in screen absolute space.
  7968. * @param projectedPosition Position in screen absolute space (X, Y)
  7969. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7970. */
  7971. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  7972. if (end === void 0) { end = false; }
  7973. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  7974. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  7975. if (end) {
  7976. this.x2 = x;
  7977. this.y2 = y;
  7978. this._x2.ignoreAdaptiveScaling = true;
  7979. this._y2.ignoreAdaptiveScaling = true;
  7980. }
  7981. else {
  7982. this.x1 = x;
  7983. this.y1 = y;
  7984. this._x1.ignoreAdaptiveScaling = true;
  7985. this._y1.ignoreAdaptiveScaling = true;
  7986. }
  7987. };
  7988. return Line;
  7989. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7990. /***/ }),
  7991. /***/ "./2D/controls/multiLine.ts":
  7992. /*!**********************************!*\
  7993. !*** ./2D/controls/multiLine.ts ***!
  7994. \**********************************/
  7995. /*! exports provided: MultiLine */
  7996. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7997. "use strict";
  7998. __webpack_require__.r(__webpack_exports__);
  7999. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8000. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8001. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/observable");
  8002. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8003. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8004. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8005. /**
  8006. * Class used to create multi line control
  8007. */
  8008. var MultiLine = /** @class */ (function (_super) {
  8009. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8010. /**
  8011. * Creates a new MultiLine
  8012. * @param name defines the control name
  8013. */
  8014. function MultiLine(name) {
  8015. var _this = _super.call(this, name) || this;
  8016. _this.name = name;
  8017. _this._lineWidth = 1;
  8018. /** Function called when a point is updated */
  8019. _this.onPointUpdate = function () {
  8020. _this._markAsDirty();
  8021. };
  8022. _this.isHitTestVisible = false;
  8023. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8024. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8025. _this._dash = [];
  8026. _this._points = [];
  8027. return _this;
  8028. }
  8029. Object.defineProperty(MultiLine.prototype, "dash", {
  8030. /** Gets or sets dash pattern */
  8031. get: function () {
  8032. return this._dash;
  8033. },
  8034. set: function (value) {
  8035. if (this._dash === value) {
  8036. return;
  8037. }
  8038. this._dash = value;
  8039. this._markAsDirty();
  8040. },
  8041. enumerable: true,
  8042. configurable: true
  8043. });
  8044. /**
  8045. * Gets point stored at specified index
  8046. * @param index defines the index to look for
  8047. * @returns the requested point if found
  8048. */
  8049. MultiLine.prototype.getAt = function (index) {
  8050. if (!this._points[index]) {
  8051. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8052. }
  8053. return this._points[index];
  8054. };
  8055. /**
  8056. * Adds new points to the point collection
  8057. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8058. * @returns the list of created MultiLinePoint
  8059. */
  8060. MultiLine.prototype.add = function () {
  8061. var _this = this;
  8062. var items = [];
  8063. for (var _i = 0; _i < arguments.length; _i++) {
  8064. items[_i] = arguments[_i];
  8065. }
  8066. return items.map(function (item) { return _this.push(item); });
  8067. };
  8068. /**
  8069. * Adds a new point to the point collection
  8070. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8071. * @returns the created MultiLinePoint
  8072. */
  8073. MultiLine.prototype.push = function (item) {
  8074. var point = this.getAt(this._points.length);
  8075. if (item == null) {
  8076. return point;
  8077. }
  8078. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8079. point.mesh = item;
  8080. }
  8081. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8082. point.control = item;
  8083. }
  8084. else if (item.x != null && item.y != null) {
  8085. point.x = item.x;
  8086. point.y = item.y;
  8087. }
  8088. return point;
  8089. };
  8090. /**
  8091. * Remove a specific value or point from the active point collection
  8092. * @param value defines the value or point to remove
  8093. */
  8094. MultiLine.prototype.remove = function (value) {
  8095. var index;
  8096. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8097. index = this._points.indexOf(value);
  8098. if (index === -1) {
  8099. return;
  8100. }
  8101. }
  8102. else {
  8103. index = value;
  8104. }
  8105. var point = this._points[index];
  8106. if (!point) {
  8107. return;
  8108. }
  8109. point.dispose();
  8110. this._points.splice(index, 1);
  8111. };
  8112. /**
  8113. * Resets this object to initial state (no point)
  8114. */
  8115. MultiLine.prototype.reset = function () {
  8116. while (this._points.length > 0) {
  8117. this.remove(this._points.length - 1);
  8118. }
  8119. };
  8120. /**
  8121. * Resets all links
  8122. */
  8123. MultiLine.prototype.resetLinks = function () {
  8124. this._points.forEach(function (point) {
  8125. if (point != null) {
  8126. point.resetLinks();
  8127. }
  8128. });
  8129. };
  8130. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8131. /** Gets or sets line width */
  8132. get: function () {
  8133. return this._lineWidth;
  8134. },
  8135. set: function (value) {
  8136. if (this._lineWidth === value) {
  8137. return;
  8138. }
  8139. this._lineWidth = value;
  8140. this._markAsDirty();
  8141. },
  8142. enumerable: true,
  8143. configurable: true
  8144. });
  8145. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8146. set: function (value) {
  8147. return;
  8148. },
  8149. enumerable: true,
  8150. configurable: true
  8151. });
  8152. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8153. set: function (value) {
  8154. return;
  8155. },
  8156. enumerable: true,
  8157. configurable: true
  8158. });
  8159. MultiLine.prototype._getTypeName = function () {
  8160. return "MultiLine";
  8161. };
  8162. MultiLine.prototype._draw = function (context) {
  8163. context.save();
  8164. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8165. context.shadowColor = this.shadowColor;
  8166. context.shadowBlur = this.shadowBlur;
  8167. context.shadowOffsetX = this.shadowOffsetX;
  8168. context.shadowOffsetY = this.shadowOffsetY;
  8169. }
  8170. this._applyStates(context);
  8171. context.strokeStyle = this.color;
  8172. context.lineWidth = this._lineWidth;
  8173. context.setLineDash(this._dash);
  8174. context.beginPath();
  8175. var first = true; //first index is not necessarily 0
  8176. this._points.forEach(function (point) {
  8177. if (!point) {
  8178. return;
  8179. }
  8180. if (first) {
  8181. context.moveTo(point._point.x, point._point.y);
  8182. first = false;
  8183. }
  8184. else {
  8185. context.lineTo(point._point.x, point._point.y);
  8186. }
  8187. });
  8188. context.stroke();
  8189. context.restore();
  8190. };
  8191. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8192. var _this = this;
  8193. this._minX = null;
  8194. this._minY = null;
  8195. this._maxX = null;
  8196. this._maxY = null;
  8197. this._points.forEach(function (point, index) {
  8198. if (!point) {
  8199. return;
  8200. }
  8201. point.translate();
  8202. if (_this._minX == null || point._point.x < _this._minX) {
  8203. _this._minX = point._point.x;
  8204. }
  8205. if (_this._minY == null || point._point.y < _this._minY) {
  8206. _this._minY = point._point.y;
  8207. }
  8208. if (_this._maxX == null || point._point.x > _this._maxX) {
  8209. _this._maxX = point._point.x;
  8210. }
  8211. if (_this._maxY == null || point._point.y > _this._maxY) {
  8212. _this._maxY = point._point.y;
  8213. }
  8214. });
  8215. if (this._minX == null) {
  8216. this._minX = 0;
  8217. }
  8218. if (this._minY == null) {
  8219. this._minY = 0;
  8220. }
  8221. if (this._maxX == null) {
  8222. this._maxX = 0;
  8223. }
  8224. if (this._maxY == null) {
  8225. this._maxY = 0;
  8226. }
  8227. };
  8228. MultiLine.prototype._measure = function () {
  8229. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8230. return;
  8231. }
  8232. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8233. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8234. };
  8235. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8236. if (this._minX == null || this._minY == null) {
  8237. return;
  8238. }
  8239. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8240. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8241. };
  8242. MultiLine.prototype.dispose = function () {
  8243. this.reset();
  8244. _super.prototype.dispose.call(this);
  8245. };
  8246. return MultiLine;
  8247. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8248. /***/ }),
  8249. /***/ "./2D/controls/radioButton.ts":
  8250. /*!************************************!*\
  8251. !*** ./2D/controls/radioButton.ts ***!
  8252. \************************************/
  8253. /*! exports provided: RadioButton */
  8254. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8255. "use strict";
  8256. __webpack_require__.r(__webpack_exports__);
  8257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8258. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8259. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  8260. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8261. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8262. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8263. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8264. /**
  8265. * Class used to create radio button controls
  8266. */
  8267. var RadioButton = /** @class */ (function (_super) {
  8268. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8269. /**
  8270. * Creates a new RadioButton
  8271. * @param name defines the control name
  8272. */
  8273. function RadioButton(name) {
  8274. var _this = _super.call(this, name) || this;
  8275. _this.name = name;
  8276. _this._isChecked = false;
  8277. _this._background = "black";
  8278. _this._checkSizeRatio = 0.8;
  8279. _this._thickness = 1;
  8280. /** Gets or sets group name */
  8281. _this.group = "";
  8282. /** Observable raised when isChecked is changed */
  8283. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8284. _this.isPointerBlocker = true;
  8285. return _this;
  8286. }
  8287. Object.defineProperty(RadioButton.prototype, "thickness", {
  8288. /** Gets or sets border thickness */
  8289. get: function () {
  8290. return this._thickness;
  8291. },
  8292. set: function (value) {
  8293. if (this._thickness === value) {
  8294. return;
  8295. }
  8296. this._thickness = value;
  8297. this._markAsDirty();
  8298. },
  8299. enumerable: true,
  8300. configurable: true
  8301. });
  8302. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8303. /** Gets or sets a value indicating the ratio between overall size and check size */
  8304. get: function () {
  8305. return this._checkSizeRatio;
  8306. },
  8307. set: function (value) {
  8308. value = Math.max(Math.min(1, value), 0);
  8309. if (this._checkSizeRatio === value) {
  8310. return;
  8311. }
  8312. this._checkSizeRatio = value;
  8313. this._markAsDirty();
  8314. },
  8315. enumerable: true,
  8316. configurable: true
  8317. });
  8318. Object.defineProperty(RadioButton.prototype, "background", {
  8319. /** Gets or sets background color */
  8320. get: function () {
  8321. return this._background;
  8322. },
  8323. set: function (value) {
  8324. if (this._background === value) {
  8325. return;
  8326. }
  8327. this._background = value;
  8328. this._markAsDirty();
  8329. },
  8330. enumerable: true,
  8331. configurable: true
  8332. });
  8333. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8334. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8335. get: function () {
  8336. return this._isChecked;
  8337. },
  8338. set: function (value) {
  8339. var _this = this;
  8340. if (this._isChecked === value) {
  8341. return;
  8342. }
  8343. this._isChecked = value;
  8344. this._markAsDirty();
  8345. this.onIsCheckedChangedObservable.notifyObservers(value);
  8346. if (this._isChecked && this._host) {
  8347. // Update all controls from same group
  8348. this._host.executeOnAllControls(function (control) {
  8349. if (control === _this) {
  8350. return;
  8351. }
  8352. if (control.group === undefined) {
  8353. return;
  8354. }
  8355. var childRadio = control;
  8356. if (childRadio.group === _this.group) {
  8357. childRadio.isChecked = false;
  8358. }
  8359. });
  8360. }
  8361. },
  8362. enumerable: true,
  8363. configurable: true
  8364. });
  8365. RadioButton.prototype._getTypeName = function () {
  8366. return "RadioButton";
  8367. };
  8368. RadioButton.prototype._draw = function (context) {
  8369. context.save();
  8370. this._applyStates(context);
  8371. var actualWidth = this._currentMeasure.width - this._thickness;
  8372. var actualHeight = this._currentMeasure.height - this._thickness;
  8373. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8374. context.shadowColor = this.shadowColor;
  8375. context.shadowBlur = this.shadowBlur;
  8376. context.shadowOffsetX = this.shadowOffsetX;
  8377. context.shadowOffsetY = this.shadowOffsetY;
  8378. }
  8379. // Outer
  8380. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  8381. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8382. context.fill();
  8383. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8384. context.shadowBlur = 0;
  8385. context.shadowOffsetX = 0;
  8386. context.shadowOffsetY = 0;
  8387. }
  8388. context.strokeStyle = this.color;
  8389. context.lineWidth = this._thickness;
  8390. context.stroke();
  8391. // Inner
  8392. if (this._isChecked) {
  8393. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8394. var offsetWidth = actualWidth * this._checkSizeRatio;
  8395. var offseHeight = actualHeight * this._checkSizeRatio;
  8396. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, offsetWidth / 2 - this._thickness / 2, offseHeight / 2 - this._thickness / 2, context);
  8397. context.fill();
  8398. }
  8399. context.restore();
  8400. };
  8401. // Events
  8402. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8403. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8404. return false;
  8405. }
  8406. if (!this.isChecked) {
  8407. this.isChecked = true;
  8408. }
  8409. return true;
  8410. };
  8411. /**
  8412. * Utility function to easily create a radio button with a header
  8413. * @param title defines the label to use for the header
  8414. * @param group defines the group to use for the radio button
  8415. * @param isChecked defines the initial state of the radio button
  8416. * @param onValueChanged defines the callback to call when value changes
  8417. * @returns a StackPanel containing the radio button and a textBlock
  8418. */
  8419. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8420. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8421. panel.isVertical = false;
  8422. panel.height = "30px";
  8423. var radio = new RadioButton();
  8424. radio.width = "20px";
  8425. radio.height = "20px";
  8426. radio.isChecked = isChecked;
  8427. radio.color = "green";
  8428. radio.group = group;
  8429. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8430. panel.addControl(radio);
  8431. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8432. header.text = title;
  8433. header.width = "180px";
  8434. header.paddingLeft = "5px";
  8435. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8436. header.color = "white";
  8437. panel.addControl(header);
  8438. return panel;
  8439. };
  8440. return RadioButton;
  8441. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8442. /***/ }),
  8443. /***/ "./2D/controls/rectangle.ts":
  8444. /*!**********************************!*\
  8445. !*** ./2D/controls/rectangle.ts ***!
  8446. \**********************************/
  8447. /*! exports provided: Rectangle */
  8448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8449. "use strict";
  8450. __webpack_require__.r(__webpack_exports__);
  8451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8452. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8453. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8454. /** Class used to create rectangle container */
  8455. var Rectangle = /** @class */ (function (_super) {
  8456. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8457. /**
  8458. * Creates a new Rectangle
  8459. * @param name defines the control name
  8460. */
  8461. function Rectangle(name) {
  8462. var _this = _super.call(this, name) || this;
  8463. _this.name = name;
  8464. _this._thickness = 1;
  8465. _this._cornerRadius = 0;
  8466. return _this;
  8467. }
  8468. Object.defineProperty(Rectangle.prototype, "thickness", {
  8469. /** Gets or sets border thickness */
  8470. get: function () {
  8471. return this._thickness;
  8472. },
  8473. set: function (value) {
  8474. if (this._thickness === value) {
  8475. return;
  8476. }
  8477. this._thickness = value;
  8478. this._markAsDirty();
  8479. },
  8480. enumerable: true,
  8481. configurable: true
  8482. });
  8483. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8484. /** Gets or sets the corner radius angle */
  8485. get: function () {
  8486. return this._cornerRadius;
  8487. },
  8488. set: function (value) {
  8489. if (value < 0) {
  8490. value = 0;
  8491. }
  8492. if (this._cornerRadius === value) {
  8493. return;
  8494. }
  8495. this._cornerRadius = value;
  8496. this._markAsDirty();
  8497. },
  8498. enumerable: true,
  8499. configurable: true
  8500. });
  8501. Rectangle.prototype._getTypeName = function () {
  8502. return "Rectangle";
  8503. };
  8504. Rectangle.prototype._localDraw = function (context) {
  8505. context.save();
  8506. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8507. context.shadowColor = this.shadowColor;
  8508. context.shadowBlur = this.shadowBlur;
  8509. context.shadowOffsetX = this.shadowOffsetX;
  8510. context.shadowOffsetY = this.shadowOffsetY;
  8511. }
  8512. if (this._background) {
  8513. context.fillStyle = this._background;
  8514. if (this._cornerRadius) {
  8515. this._drawRoundedRect(context, this._thickness / 2);
  8516. context.fill();
  8517. }
  8518. else {
  8519. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8520. }
  8521. }
  8522. if (this._thickness) {
  8523. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8524. context.shadowBlur = 0;
  8525. context.shadowOffsetX = 0;
  8526. context.shadowOffsetY = 0;
  8527. }
  8528. if (this.color) {
  8529. context.strokeStyle = this.color;
  8530. }
  8531. context.lineWidth = this._thickness;
  8532. if (this._cornerRadius) {
  8533. this._drawRoundedRect(context, this._thickness / 2);
  8534. context.stroke();
  8535. }
  8536. else {
  8537. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8538. }
  8539. }
  8540. context.restore();
  8541. };
  8542. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8543. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8544. this._measureForChildren.width -= 2 * this._thickness;
  8545. this._measureForChildren.height -= 2 * this._thickness;
  8546. this._measureForChildren.left += this._thickness;
  8547. this._measureForChildren.top += this._thickness;
  8548. };
  8549. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8550. if (offset === void 0) { offset = 0; }
  8551. var x = this._currentMeasure.left + offset;
  8552. var y = this._currentMeasure.top + offset;
  8553. var width = this._currentMeasure.width - offset * 2;
  8554. var height = this._currentMeasure.height - offset * 2;
  8555. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8556. context.beginPath();
  8557. context.moveTo(x + radius, y);
  8558. context.lineTo(x + width - radius, y);
  8559. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8560. context.lineTo(x + width, y + height - radius);
  8561. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8562. context.lineTo(x + radius, y + height);
  8563. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8564. context.lineTo(x, y + radius);
  8565. context.quadraticCurveTo(x, y, x + radius, y);
  8566. context.closePath();
  8567. };
  8568. Rectangle.prototype._clipForChildren = function (context) {
  8569. if (this._cornerRadius) {
  8570. this._drawRoundedRect(context, this._thickness);
  8571. context.clip();
  8572. }
  8573. };
  8574. return Rectangle;
  8575. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8576. /***/ }),
  8577. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8578. /*!***************************************************!*\
  8579. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8580. \***************************************************/
  8581. /*! exports provided: ScrollViewer */
  8582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8583. "use strict";
  8584. __webpack_require__.r(__webpack_exports__);
  8585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8586. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8587. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/observable");
  8588. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8589. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8590. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8591. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8592. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8593. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8594. /**
  8595. * Class used to hold a viewer window and sliders in a grid
  8596. */
  8597. var ScrollViewer = /** @class */ (function (_super) {
  8598. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8599. /**
  8600. * Creates a new ScrollViewer
  8601. * @param name of ScrollViewer
  8602. */
  8603. function ScrollViewer(name) {
  8604. var _this = _super.call(this, name) || this;
  8605. _this._barSize = 20;
  8606. _this._pointerIsOver = false;
  8607. _this._wheelPrecision = 0.05;
  8608. _this.onDirtyObservable.add(function () {
  8609. _this._horizontalBarSpace.color = _this.color;
  8610. _this._verticalBarSpace.color = _this.color;
  8611. _this._dragSpace.color = _this.color;
  8612. });
  8613. _this.onPointerEnterObservable.add(function () {
  8614. _this._pointerIsOver = true;
  8615. });
  8616. _this.onPointerOutObservable.add(function () {
  8617. _this._pointerIsOver = false;
  8618. });
  8619. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8620. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8621. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8622. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8623. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8624. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8625. _this._grid.addColumnDefinition(1);
  8626. _this._grid.addColumnDefinition(0, true);
  8627. _this._grid.addRowDefinition(1);
  8628. _this._grid.addRowDefinition(0, true);
  8629. _super.prototype.addControl.call(_this, _this._grid);
  8630. _this._grid.addControl(_this._window, 0, 0);
  8631. _this._verticalBar.paddingLeft = 0;
  8632. _this._verticalBar.width = "100%";
  8633. _this._verticalBar.height = "100%";
  8634. _this._verticalBar.barOffset = 0;
  8635. _this._verticalBar.value = 0;
  8636. _this._verticalBar.maximum = 1;
  8637. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8638. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8639. _this._verticalBar.isVertical = true;
  8640. _this._verticalBar.rotation = Math.PI;
  8641. _this._verticalBar.isVisible = false;
  8642. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8643. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8644. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8645. _this._verticalBarSpace.thickness = 1;
  8646. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8647. _this._verticalBarSpace.addControl(_this._verticalBar);
  8648. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8649. _this._window.top = value * _this._endTop + "px";
  8650. });
  8651. _this._horizontalBar.paddingLeft = 0;
  8652. _this._horizontalBar.width = "100%";
  8653. _this._horizontalBar.height = "100%";
  8654. _this._horizontalBar.barOffset = 0;
  8655. _this._horizontalBar.value = 0;
  8656. _this._horizontalBar.maximum = 1;
  8657. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8658. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8659. _this._horizontalBar.isVisible = false;
  8660. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8661. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8662. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8663. _this._horizontalBarSpace.thickness = 1;
  8664. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8665. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8666. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8667. _this._window.left = value * _this._endLeft + "px";
  8668. });
  8669. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8670. _this._dragSpace.thickness = 1;
  8671. _this._grid.addControl(_this._dragSpace, 1, 1);
  8672. // Colors
  8673. _this.barColor = "grey";
  8674. _this.barBackground = "transparent";
  8675. return _this;
  8676. }
  8677. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8678. /**
  8679. * Gets the horizontal scrollbar
  8680. */
  8681. get: function () {
  8682. return this._horizontalBar;
  8683. },
  8684. enumerable: true,
  8685. configurable: true
  8686. });
  8687. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8688. /**
  8689. * Gets the vertical scrollbar
  8690. */
  8691. get: function () {
  8692. return this._verticalBar;
  8693. },
  8694. enumerable: true,
  8695. configurable: true
  8696. });
  8697. /**
  8698. * Adds a new control to the current container
  8699. * @param control defines the control to add
  8700. * @returns the current container
  8701. */
  8702. ScrollViewer.prototype.addControl = function (control) {
  8703. if (!control) {
  8704. return this;
  8705. }
  8706. this._window.addControl(control);
  8707. return this;
  8708. };
  8709. /**
  8710. * Removes a control from the current container
  8711. * @param control defines the control to remove
  8712. * @returns the current container
  8713. */
  8714. ScrollViewer.prototype.removeControl = function (control) {
  8715. this._window.removeControl(control);
  8716. return this;
  8717. };
  8718. Object.defineProperty(ScrollViewer.prototype, "children", {
  8719. /** Gets the list of children */
  8720. get: function () {
  8721. return this._window.children;
  8722. },
  8723. enumerable: true,
  8724. configurable: true
  8725. });
  8726. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8727. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8728. var child = _a[_i];
  8729. child._markMatrixAsDirty();
  8730. }
  8731. };
  8732. /** Reset the scroll viewer window to initial size */
  8733. ScrollViewer.prototype.resetWindow = function () {
  8734. this._window.width = "100%";
  8735. this._window.height = "100%";
  8736. };
  8737. ScrollViewer.prototype._getTypeName = function () {
  8738. return "ScrollViewer";
  8739. };
  8740. ScrollViewer.prototype._buildClientSizes = function () {
  8741. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8742. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8743. this._clientWidth = this._window.parentClientWidth;
  8744. this._clientHeight = this._window.parentClientHeight;
  8745. };
  8746. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8747. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8748. this._buildClientSizes();
  8749. };
  8750. ScrollViewer.prototype._postMeasure = function () {
  8751. _super.prototype._postMeasure.call(this);
  8752. this._updateScroller();
  8753. };
  8754. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8755. /**
  8756. * Gets or sets the mouse wheel precision
  8757. * from 0 to 1 with a default value of 0.05
  8758. * */
  8759. get: function () {
  8760. return this._wheelPrecision;
  8761. },
  8762. set: function (value) {
  8763. if (this._wheelPrecision === value) {
  8764. return;
  8765. }
  8766. if (value < 0) {
  8767. value = 0;
  8768. }
  8769. if (value > 1) {
  8770. value = 1;
  8771. }
  8772. this._wheelPrecision = value;
  8773. },
  8774. enumerable: true,
  8775. configurable: true
  8776. });
  8777. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8778. /** Gets or sets the bar color */
  8779. get: function () {
  8780. return this._barColor;
  8781. },
  8782. set: function (color) {
  8783. if (this._barColor === color) {
  8784. return;
  8785. }
  8786. this._barColor = color;
  8787. this._horizontalBar.color = color;
  8788. this._verticalBar.color = color;
  8789. },
  8790. enumerable: true,
  8791. configurable: true
  8792. });
  8793. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8794. /** Gets or sets the size of the bar */
  8795. get: function () {
  8796. return this._barSize;
  8797. },
  8798. set: function (value) {
  8799. if (this._barSize === value) {
  8800. return;
  8801. }
  8802. this._barSize = value;
  8803. this._markAsDirty();
  8804. if (this._horizontalBar.isVisible) {
  8805. this._grid.setRowDefinition(1, this._barSize, true);
  8806. }
  8807. if (this._verticalBar.isVisible) {
  8808. this._grid.setColumnDefinition(1, this._barSize, true);
  8809. }
  8810. },
  8811. enumerable: true,
  8812. configurable: true
  8813. });
  8814. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8815. /** Gets or sets the bar background */
  8816. get: function () {
  8817. return this._barBackground;
  8818. },
  8819. set: function (color) {
  8820. if (this._barBackground === color) {
  8821. return;
  8822. }
  8823. this._barBackground = color;
  8824. this._horizontalBar.background = color;
  8825. this._verticalBar.background = color;
  8826. this._dragSpace.background = color;
  8827. },
  8828. enumerable: true,
  8829. configurable: true
  8830. });
  8831. /** @hidden */
  8832. ScrollViewer.prototype._updateScroller = function () {
  8833. var windowContentsWidth = this._window._currentMeasure.width;
  8834. var windowContentsHeight = this._window._currentMeasure.height;
  8835. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8836. this._grid.setRowDefinition(1, 0, true);
  8837. this._horizontalBar.isVisible = false;
  8838. this._horizontalBar.value = 0;
  8839. this._rebuildLayout = true;
  8840. }
  8841. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8842. this._grid.setRowDefinition(1, this._barSize, true);
  8843. this._horizontalBar.isVisible = true;
  8844. this._rebuildLayout = true;
  8845. }
  8846. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8847. this._grid.setColumnDefinition(1, 0, true);
  8848. this._verticalBar.isVisible = false;
  8849. this._verticalBar.value = 0;
  8850. this._rebuildLayout = true;
  8851. }
  8852. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8853. this._grid.setColumnDefinition(1, this._barSize, true);
  8854. this._verticalBar.isVisible = true;
  8855. this._rebuildLayout = true;
  8856. }
  8857. this._buildClientSizes();
  8858. this._endLeft = this._clientWidth - windowContentsWidth;
  8859. this._endTop = this._clientHeight - windowContentsHeight;
  8860. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8861. var newTop = this._verticalBar.value * this._endTop + "px";
  8862. if (newLeft !== this._window.left) {
  8863. this._window.left = newLeft;
  8864. this._rebuildLayout = true;
  8865. }
  8866. if (newTop !== this._window.top) {
  8867. this._window.top = newTop;
  8868. this._rebuildLayout = true;
  8869. }
  8870. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8871. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8872. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8873. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8874. };
  8875. ScrollViewer.prototype._link = function (host) {
  8876. _super.prototype._link.call(this, host);
  8877. this._attachWheel();
  8878. };
  8879. /** @hidden */
  8880. ScrollViewer.prototype._attachWheel = function () {
  8881. var _this = this;
  8882. if (this._onPointerObserver) {
  8883. return;
  8884. }
  8885. var scene = this._host.getScene();
  8886. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8887. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8888. return;
  8889. }
  8890. if (_this._verticalBar.isVisible == true) {
  8891. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8892. _this._verticalBar.value -= _this._wheelPrecision;
  8893. }
  8894. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8895. _this._verticalBar.value += _this._wheelPrecision;
  8896. }
  8897. }
  8898. if (_this._horizontalBar.isVisible == true) {
  8899. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8900. _this._horizontalBar.value += _this._wheelPrecision;
  8901. }
  8902. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8903. _this._horizontalBar.value -= _this._wheelPrecision;
  8904. }
  8905. }
  8906. });
  8907. };
  8908. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8909. if (!this.isHighlighted) {
  8910. return;
  8911. }
  8912. _super.prototype._renderHighlightSpecific.call(this, context);
  8913. this._grid._renderHighlightSpecific(context);
  8914. context.restore();
  8915. };
  8916. /** Releases associated resources */
  8917. ScrollViewer.prototype.dispose = function () {
  8918. var scene = this._host.getScene();
  8919. if (scene && this._onPointerObserver) {
  8920. scene.onPointerObservable.remove(this._onPointerObserver);
  8921. this._onPointerObserver = null;
  8922. }
  8923. _super.prototype.dispose.call(this);
  8924. };
  8925. return ScrollViewer;
  8926. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  8927. /***/ }),
  8928. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  8929. /*!*********************************************************!*\
  8930. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  8931. \*********************************************************/
  8932. /*! exports provided: _ScrollViewerWindow */
  8933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8934. "use strict";
  8935. __webpack_require__.r(__webpack_exports__);
  8936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  8937. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8938. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  8939. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  8940. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8941. /**
  8942. * Class used to hold a the container for ScrollViewer
  8943. * @hidden
  8944. */
  8945. var _ScrollViewerWindow = /** @class */ (function (_super) {
  8946. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  8947. /**
  8948. * Creates a new ScrollViewerWindow
  8949. * @param name of ScrollViewerWindow
  8950. */
  8951. function _ScrollViewerWindow(name) {
  8952. return _super.call(this, name) || this;
  8953. }
  8954. _ScrollViewerWindow.prototype._getTypeName = function () {
  8955. return "ScrollViewerWindow";
  8956. };
  8957. /** @hidden */
  8958. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  8959. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8960. this._measureForChildren.left = this._currentMeasure.left;
  8961. this._measureForChildren.top = this._currentMeasure.top;
  8962. this._measureForChildren.width = parentMeasure.width;
  8963. this._measureForChildren.height = parentMeasure.height;
  8964. };
  8965. _ScrollViewerWindow.prototype._postMeasure = function () {
  8966. var maxWidth = this.parentClientWidth;
  8967. var maxHeight = this.parentClientHeight;
  8968. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  8969. var child = _a[_i];
  8970. if (!child.isVisible || child.notRenderable) {
  8971. continue;
  8972. }
  8973. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  8974. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  8975. }
  8976. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  8977. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  8978. }
  8979. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  8980. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  8981. }
  8982. if (this._currentMeasure.width !== maxWidth) {
  8983. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  8984. this._currentMeasure.width = maxWidth;
  8985. this._rebuildLayout = true;
  8986. this._isDirty = true;
  8987. }
  8988. if (this._currentMeasure.height !== maxHeight) {
  8989. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  8990. this._currentMeasure.height = maxHeight;
  8991. this._rebuildLayout = true;
  8992. this._isDirty = true;
  8993. }
  8994. _super.prototype._postMeasure.call(this);
  8995. };
  8996. return _ScrollViewerWindow;
  8997. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8998. /***/ }),
  8999. /***/ "./2D/controls/selector.ts":
  9000. /*!*********************************!*\
  9001. !*** ./2D/controls/selector.ts ***!
  9002. \*********************************/
  9003. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9005. "use strict";
  9006. __webpack_require__.r(__webpack_exports__);
  9007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9010. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9012. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9013. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9014. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9015. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9016. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9017. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9018. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9019. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9020. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9021. /** Class used to create a RadioGroup
  9022. * which contains groups of radio buttons
  9023. */
  9024. var SelectorGroup = /** @class */ (function () {
  9025. /**
  9026. * Creates a new SelectorGroup
  9027. * @param name of group, used as a group heading
  9028. */
  9029. function SelectorGroup(
  9030. /** name of SelectorGroup */
  9031. name) {
  9032. this.name = name;
  9033. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9034. this._selectors = new Array();
  9035. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9036. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9037. this._groupHeader = this._addGroupHeader(name);
  9038. }
  9039. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9040. /** Gets the groupPanel of the SelectorGroup */
  9041. get: function () {
  9042. return this._groupPanel;
  9043. },
  9044. enumerable: true,
  9045. configurable: true
  9046. });
  9047. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9048. /** Gets the selectors array */
  9049. get: function () {
  9050. return this._selectors;
  9051. },
  9052. enumerable: true,
  9053. configurable: true
  9054. });
  9055. Object.defineProperty(SelectorGroup.prototype, "header", {
  9056. /** Gets and sets the group header */
  9057. get: function () {
  9058. return this._groupHeader.text;
  9059. },
  9060. set: function (label) {
  9061. if (this._groupHeader.text === "label") {
  9062. return;
  9063. }
  9064. this._groupHeader.text = label;
  9065. },
  9066. enumerable: true,
  9067. configurable: true
  9068. });
  9069. /** @hidden */
  9070. SelectorGroup.prototype._addGroupHeader = function (text) {
  9071. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9072. groupHeading.width = 0.9;
  9073. groupHeading.height = "30px";
  9074. groupHeading.textWrapping = true;
  9075. groupHeading.color = "black";
  9076. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9077. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9078. groupHeading.left = "2px";
  9079. this._groupPanel.addControl(groupHeading);
  9080. return groupHeading;
  9081. };
  9082. /** @hidden*/
  9083. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9084. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9085. return;
  9086. }
  9087. return this._selectors[selectorNb];
  9088. };
  9089. /** Removes the selector at the given position
  9090. * @param selectorNb the position of the selector within the group
  9091. */
  9092. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9093. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9094. return;
  9095. }
  9096. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9097. this._selectors.splice(selectorNb, 1);
  9098. };
  9099. return SelectorGroup;
  9100. }());
  9101. /** Class used to create a CheckboxGroup
  9102. * which contains groups of checkbox buttons
  9103. */
  9104. var CheckboxGroup = /** @class */ (function (_super) {
  9105. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9106. function CheckboxGroup() {
  9107. return _super !== null && _super.apply(this, arguments) || this;
  9108. }
  9109. /** Adds a checkbox as a control
  9110. * @param text is the label for the selector
  9111. * @param func is the function called when the Selector is checked
  9112. * @param checked is true when Selector is checked
  9113. */
  9114. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9115. if (func === void 0) { func = function (s) { }; }
  9116. if (checked === void 0) { checked = false; }
  9117. var checked = checked || false;
  9118. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9119. button.width = "20px";
  9120. button.height = "20px";
  9121. button.color = "#364249";
  9122. button.background = "#CCCCCC";
  9123. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9124. button.onIsCheckedChangedObservable.add(function (state) {
  9125. func(state);
  9126. });
  9127. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9128. _selector.height = "30px";
  9129. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9130. _selector.left = "4px";
  9131. this.groupPanel.addControl(_selector);
  9132. this.selectors.push(_selector);
  9133. button.isChecked = checked;
  9134. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9135. button.color = this.groupPanel.parent.parent.buttonColor;
  9136. button.background = this.groupPanel.parent.parent.buttonBackground;
  9137. }
  9138. };
  9139. /** @hidden */
  9140. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9141. this.selectors[selectorNb].children[1].text = label;
  9142. };
  9143. /** @hidden */
  9144. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9145. this.selectors[selectorNb].children[1].color = color;
  9146. };
  9147. /** @hidden */
  9148. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9149. this.selectors[selectorNb].children[0].color = color;
  9150. };
  9151. /** @hidden */
  9152. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9153. this.selectors[selectorNb].children[0].background = color;
  9154. };
  9155. return CheckboxGroup;
  9156. }(SelectorGroup));
  9157. /** Class used to create a RadioGroup
  9158. * which contains groups of radio buttons
  9159. */
  9160. var RadioGroup = /** @class */ (function (_super) {
  9161. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9162. function RadioGroup() {
  9163. var _this = _super !== null && _super.apply(this, arguments) || this;
  9164. _this._selectNb = 0;
  9165. return _this;
  9166. }
  9167. /** Adds a radio button as a control
  9168. * @param label is the label for the selector
  9169. * @param func is the function called when the Selector is checked
  9170. * @param checked is true when Selector is checked
  9171. */
  9172. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9173. if (func === void 0) { func = function (n) { }; }
  9174. if (checked === void 0) { checked = false; }
  9175. var nb = this._selectNb++;
  9176. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9177. button.name = label;
  9178. button.width = "20px";
  9179. button.height = "20px";
  9180. button.color = "#364249";
  9181. button.background = "#CCCCCC";
  9182. button.group = this.name;
  9183. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9184. button.onIsCheckedChangedObservable.add(function (state) {
  9185. if (state) {
  9186. func(nb);
  9187. }
  9188. });
  9189. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9190. _selector.height = "30px";
  9191. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9192. _selector.left = "4px";
  9193. this.groupPanel.addControl(_selector);
  9194. this.selectors.push(_selector);
  9195. button.isChecked = checked;
  9196. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9197. button.color = this.groupPanel.parent.parent.buttonColor;
  9198. button.background = this.groupPanel.parent.parent.buttonBackground;
  9199. }
  9200. };
  9201. /** @hidden */
  9202. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9203. this.selectors[selectorNb].children[1].text = label;
  9204. };
  9205. /** @hidden */
  9206. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9207. this.selectors[selectorNb].children[1].color = color;
  9208. };
  9209. /** @hidden */
  9210. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9211. this.selectors[selectorNb].children[0].color = color;
  9212. };
  9213. /** @hidden */
  9214. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9215. this.selectors[selectorNb].children[0].background = color;
  9216. };
  9217. return RadioGroup;
  9218. }(SelectorGroup));
  9219. /** Class used to create a SliderGroup
  9220. * which contains groups of slider buttons
  9221. */
  9222. var SliderGroup = /** @class */ (function (_super) {
  9223. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9224. function SliderGroup() {
  9225. return _super !== null && _super.apply(this, arguments) || this;
  9226. }
  9227. /**
  9228. * Adds a slider to the SelectorGroup
  9229. * @param label is the label for the SliderBar
  9230. * @param func is the function called when the Slider moves
  9231. * @param unit is a string describing the units used, eg degrees or metres
  9232. * @param min is the minimum value for the Slider
  9233. * @param max is the maximum value for the Slider
  9234. * @param value is the start value for the Slider between min and max
  9235. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9236. */
  9237. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9238. if (func === void 0) { func = function (v) { }; }
  9239. if (unit === void 0) { unit = "Units"; }
  9240. if (min === void 0) { min = 0; }
  9241. if (max === void 0) { max = 0; }
  9242. if (value === void 0) { value = 0; }
  9243. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9244. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9245. button.name = unit;
  9246. button.value = value;
  9247. button.minimum = min;
  9248. button.maximum = max;
  9249. button.width = 0.9;
  9250. button.height = "20px";
  9251. button.color = "#364249";
  9252. button.background = "#CCCCCC";
  9253. button.borderColor = "black";
  9254. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9255. button.left = "4px";
  9256. button.paddingBottom = "4px";
  9257. button.onValueChangedObservable.add(function (value) {
  9258. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9259. func(value);
  9260. });
  9261. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9262. _selector.height = "60px";
  9263. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9264. _selector.left = "4px";
  9265. _selector.children[0].name = label;
  9266. this.groupPanel.addControl(_selector);
  9267. this.selectors.push(_selector);
  9268. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9269. button.color = this.groupPanel.parent.parent.buttonColor;
  9270. button.background = this.groupPanel.parent.parent.buttonBackground;
  9271. }
  9272. };
  9273. /** @hidden */
  9274. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9275. this.selectors[selectorNb].children[0].name = label;
  9276. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9277. };
  9278. /** @hidden */
  9279. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9280. this.selectors[selectorNb].children[0].color = color;
  9281. };
  9282. /** @hidden */
  9283. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9284. this.selectors[selectorNb].children[1].color = color;
  9285. };
  9286. /** @hidden */
  9287. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9288. this.selectors[selectorNb].children[1].background = color;
  9289. };
  9290. return SliderGroup;
  9291. }(SelectorGroup));
  9292. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9293. * @see http://doc.babylonjs.com/how_to/selector
  9294. */
  9295. var SelectionPanel = /** @class */ (function (_super) {
  9296. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9297. /**
  9298. * Creates a new SelectionPanel
  9299. * @param name of SelectionPanel
  9300. * @param groups is an array of SelectionGroups
  9301. */
  9302. function SelectionPanel(
  9303. /** name of SelectionPanel */
  9304. name,
  9305. /** an array of SelectionGroups */
  9306. groups) {
  9307. if (groups === void 0) { groups = []; }
  9308. var _this = _super.call(this, name) || this;
  9309. _this.name = name;
  9310. _this.groups = groups;
  9311. _this._buttonColor = "#364249";
  9312. _this._buttonBackground = "#CCCCCC";
  9313. _this._headerColor = "black";
  9314. _this._barColor = "white";
  9315. _this._barHeight = "2px";
  9316. _this._spacerHeight = "20px";
  9317. _this._bars = new Array();
  9318. _this._groups = groups;
  9319. _this.thickness = 2;
  9320. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9321. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9322. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9323. _this._panel.top = 5;
  9324. _this._panel.left = 5;
  9325. _this._panel.width = 0.95;
  9326. if (groups.length > 0) {
  9327. for (var i = 0; i < groups.length - 1; i++) {
  9328. _this._panel.addControl(groups[i].groupPanel);
  9329. _this._addSpacer();
  9330. }
  9331. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9332. }
  9333. _this.addControl(_this._panel);
  9334. return _this;
  9335. }
  9336. SelectionPanel.prototype._getTypeName = function () {
  9337. return "SelectionPanel";
  9338. };
  9339. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9340. /** Gets or sets the headerColor */
  9341. get: function () {
  9342. return this._headerColor;
  9343. },
  9344. set: function (color) {
  9345. if (this._headerColor === color) {
  9346. return;
  9347. }
  9348. this._headerColor = color;
  9349. this._setHeaderColor();
  9350. },
  9351. enumerable: true,
  9352. configurable: true
  9353. });
  9354. SelectionPanel.prototype._setHeaderColor = function () {
  9355. for (var i = 0; i < this._groups.length; i++) {
  9356. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9357. }
  9358. };
  9359. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9360. /** Gets or sets the button color */
  9361. get: function () {
  9362. return this._buttonColor;
  9363. },
  9364. set: function (color) {
  9365. if (this._buttonColor === color) {
  9366. return;
  9367. }
  9368. this._buttonColor = color;
  9369. this._setbuttonColor();
  9370. },
  9371. enumerable: true,
  9372. configurable: true
  9373. });
  9374. SelectionPanel.prototype._setbuttonColor = function () {
  9375. for (var i = 0; i < this._groups.length; i++) {
  9376. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9377. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9378. }
  9379. }
  9380. };
  9381. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9382. /** Gets or sets the label color */
  9383. get: function () {
  9384. return this._labelColor;
  9385. },
  9386. set: function (color) {
  9387. if (this._labelColor === color) {
  9388. return;
  9389. }
  9390. this._labelColor = color;
  9391. this._setLabelColor();
  9392. },
  9393. enumerable: true,
  9394. configurable: true
  9395. });
  9396. SelectionPanel.prototype._setLabelColor = function () {
  9397. for (var i = 0; i < this._groups.length; i++) {
  9398. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9399. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9400. }
  9401. }
  9402. };
  9403. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9404. /** Gets or sets the button background */
  9405. get: function () {
  9406. return this._buttonBackground;
  9407. },
  9408. set: function (color) {
  9409. if (this._buttonBackground === color) {
  9410. return;
  9411. }
  9412. this._buttonBackground = color;
  9413. this._setButtonBackground();
  9414. },
  9415. enumerable: true,
  9416. configurable: true
  9417. });
  9418. SelectionPanel.prototype._setButtonBackground = function () {
  9419. for (var i = 0; i < this._groups.length; i++) {
  9420. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9421. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9422. }
  9423. }
  9424. };
  9425. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9426. /** Gets or sets the color of separator bar */
  9427. get: function () {
  9428. return this._barColor;
  9429. },
  9430. set: function (color) {
  9431. if (this._barColor === color) {
  9432. return;
  9433. }
  9434. this._barColor = color;
  9435. this._setBarColor();
  9436. },
  9437. enumerable: true,
  9438. configurable: true
  9439. });
  9440. SelectionPanel.prototype._setBarColor = function () {
  9441. for (var i = 0; i < this._bars.length; i++) {
  9442. this._bars[i].children[0].background = this._barColor;
  9443. }
  9444. };
  9445. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9446. /** Gets or sets the height of separator bar */
  9447. get: function () {
  9448. return this._barHeight;
  9449. },
  9450. set: function (value) {
  9451. if (this._barHeight === value) {
  9452. return;
  9453. }
  9454. this._barHeight = value;
  9455. this._setBarHeight();
  9456. },
  9457. enumerable: true,
  9458. configurable: true
  9459. });
  9460. SelectionPanel.prototype._setBarHeight = function () {
  9461. for (var i = 0; i < this._bars.length; i++) {
  9462. this._bars[i].children[0].height = this._barHeight;
  9463. }
  9464. };
  9465. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9466. /** Gets or sets the height of spacers*/
  9467. get: function () {
  9468. return this._spacerHeight;
  9469. },
  9470. set: function (value) {
  9471. if (this._spacerHeight === value) {
  9472. return;
  9473. }
  9474. this._spacerHeight = value;
  9475. this._setSpacerHeight();
  9476. },
  9477. enumerable: true,
  9478. configurable: true
  9479. });
  9480. SelectionPanel.prototype._setSpacerHeight = function () {
  9481. for (var i = 0; i < this._bars.length; i++) {
  9482. this._bars[i].height = this._spacerHeight;
  9483. }
  9484. };
  9485. /** Adds a bar between groups */
  9486. SelectionPanel.prototype._addSpacer = function () {
  9487. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9488. separator.width = 1;
  9489. separator.height = this._spacerHeight;
  9490. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9491. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9492. bar.width = 1;
  9493. bar.height = this._barHeight;
  9494. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9495. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9496. bar.background = this._barColor;
  9497. bar.color = "transparent";
  9498. separator.addControl(bar);
  9499. this._panel.addControl(separator);
  9500. this._bars.push(separator);
  9501. };
  9502. /** Add a group to the selection panel
  9503. * @param group is the selector group to add
  9504. */
  9505. SelectionPanel.prototype.addGroup = function (group) {
  9506. if (this._groups.length > 0) {
  9507. this._addSpacer();
  9508. }
  9509. this._panel.addControl(group.groupPanel);
  9510. this._groups.push(group);
  9511. group.groupPanel.children[0].color = this._headerColor;
  9512. for (var j = 0; j < group.selectors.length; j++) {
  9513. group._setSelectorButtonColor(j, this._buttonColor);
  9514. group._setSelectorButtonBackground(j, this._buttonBackground);
  9515. }
  9516. };
  9517. /** Remove the group from the given position
  9518. * @param groupNb is the position of the group in the list
  9519. */
  9520. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9521. if (groupNb < 0 || groupNb >= this._groups.length) {
  9522. return;
  9523. }
  9524. var group = this._groups[groupNb];
  9525. this._panel.removeControl(group.groupPanel);
  9526. this._groups.splice(groupNb, 1);
  9527. if (groupNb < this._bars.length) {
  9528. this._panel.removeControl(this._bars[groupNb]);
  9529. this._bars.splice(groupNb, 1);
  9530. }
  9531. };
  9532. /** Change a group header label
  9533. * @param label is the new group header label
  9534. * @param groupNb is the number of the group to relabel
  9535. * */
  9536. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9537. if (groupNb < 0 || groupNb >= this._groups.length) {
  9538. return;
  9539. }
  9540. var group = this._groups[groupNb];
  9541. group.groupPanel.children[0].text = label;
  9542. };
  9543. /** Change selector label to the one given
  9544. * @param label is the new selector label
  9545. * @param groupNb is the number of the groupcontaining the selector
  9546. * @param selectorNb is the number of the selector within a group to relabel
  9547. * */
  9548. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9549. if (groupNb < 0 || groupNb >= this._groups.length) {
  9550. return;
  9551. }
  9552. var group = this._groups[groupNb];
  9553. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9554. return;
  9555. }
  9556. group._setSelectorLabel(selectorNb, label);
  9557. };
  9558. /** For a given group position remove the selector at the given position
  9559. * @param groupNb is the number of the group to remove the selector from
  9560. * @param selectorNb is the number of the selector within the group
  9561. */
  9562. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9563. if (groupNb < 0 || groupNb >= this._groups.length) {
  9564. return;
  9565. }
  9566. var group = this._groups[groupNb];
  9567. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9568. return;
  9569. }
  9570. group.removeSelector(selectorNb);
  9571. };
  9572. /** For a given group position of correct type add a checkbox button
  9573. * @param groupNb is the number of the group to remove the selector from
  9574. * @param label is the label for the selector
  9575. * @param func is the function called when the Selector is checked
  9576. * @param checked is true when Selector is checked
  9577. */
  9578. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9579. if (func === void 0) { func = function () { }; }
  9580. if (checked === void 0) { checked = false; }
  9581. if (groupNb < 0 || groupNb >= this._groups.length) {
  9582. return;
  9583. }
  9584. var group = this._groups[groupNb];
  9585. group.addCheckbox(label, func, checked);
  9586. };
  9587. /** For a given group position of correct type add a radio button
  9588. * @param groupNb is the number of the group to remove the selector from
  9589. * @param label is the label for the selector
  9590. * @param func is the function called when the Selector is checked
  9591. * @param checked is true when Selector is checked
  9592. */
  9593. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9594. if (func === void 0) { func = function () { }; }
  9595. if (checked === void 0) { checked = false; }
  9596. if (groupNb < 0 || groupNb >= this._groups.length) {
  9597. return;
  9598. }
  9599. var group = this._groups[groupNb];
  9600. group.addRadio(label, func, checked);
  9601. };
  9602. /**
  9603. * For a given slider group add a slider
  9604. * @param groupNb is the number of the group to add the slider to
  9605. * @param label is the label for the Slider
  9606. * @param func is the function called when the Slider moves
  9607. * @param unit is a string describing the units used, eg degrees or metres
  9608. * @param min is the minimum value for the Slider
  9609. * @param max is the maximum value for the Slider
  9610. * @param value is the start value for the Slider between min and max
  9611. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9612. */
  9613. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9614. if (func === void 0) { func = function () { }; }
  9615. if (unit === void 0) { unit = "Units"; }
  9616. if (min === void 0) { min = 0; }
  9617. if (max === void 0) { max = 0; }
  9618. if (value === void 0) { value = 0; }
  9619. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9620. if (groupNb < 0 || groupNb >= this._groups.length) {
  9621. return;
  9622. }
  9623. var group = this._groups[groupNb];
  9624. group.addSlider(label, func, unit, min, max, value, onVal);
  9625. };
  9626. return SelectionPanel;
  9627. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9628. /***/ }),
  9629. /***/ "./2D/controls/sliders/baseSlider.ts":
  9630. /*!*******************************************!*\
  9631. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9632. \*******************************************/
  9633. /*! exports provided: BaseSlider */
  9634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9635. "use strict";
  9636. __webpack_require__.r(__webpack_exports__);
  9637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9638. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9639. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  9640. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9641. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9642. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9643. /**
  9644. * Class used to create slider controls
  9645. */
  9646. var BaseSlider = /** @class */ (function (_super) {
  9647. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9648. /**
  9649. * Creates a new BaseSlider
  9650. * @param name defines the control name
  9651. */
  9652. function BaseSlider(name) {
  9653. var _this = _super.call(this, name) || this;
  9654. _this.name = name;
  9655. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9656. _this._minimum = 0;
  9657. _this._maximum = 100;
  9658. _this._value = 50;
  9659. _this._isVertical = false;
  9660. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9661. _this._isThumbClamped = false;
  9662. _this._displayThumb = true;
  9663. // Shared rendering info
  9664. _this._effectiveBarOffset = 0;
  9665. /** Observable raised when the sldier value changes */
  9666. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9667. // Events
  9668. _this._pointerIsDown = false;
  9669. _this.isPointerBlocker = true;
  9670. return _this;
  9671. }
  9672. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9673. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9674. get: function () {
  9675. return this._displayThumb;
  9676. },
  9677. set: function (value) {
  9678. if (this._displayThumb === value) {
  9679. return;
  9680. }
  9681. this._displayThumb = value;
  9682. this._markAsDirty();
  9683. },
  9684. enumerable: true,
  9685. configurable: true
  9686. });
  9687. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9688. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9689. get: function () {
  9690. return this._barOffset.toString(this._host);
  9691. },
  9692. set: function (value) {
  9693. if (this._barOffset.toString(this._host) === value) {
  9694. return;
  9695. }
  9696. if (this._barOffset.fromString(value)) {
  9697. this._markAsDirty();
  9698. }
  9699. },
  9700. enumerable: true,
  9701. configurable: true
  9702. });
  9703. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9704. /** Gets main bar offset in pixels*/
  9705. get: function () {
  9706. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9707. },
  9708. enumerable: true,
  9709. configurable: true
  9710. });
  9711. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9712. /** Gets or sets thumb width */
  9713. get: function () {
  9714. return this._thumbWidth.toString(this._host);
  9715. },
  9716. set: function (value) {
  9717. if (this._thumbWidth.toString(this._host) === value) {
  9718. return;
  9719. }
  9720. if (this._thumbWidth.fromString(value)) {
  9721. this._markAsDirty();
  9722. }
  9723. },
  9724. enumerable: true,
  9725. configurable: true
  9726. });
  9727. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9728. /** Gets thumb width in pixels */
  9729. get: function () {
  9730. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9731. },
  9732. enumerable: true,
  9733. configurable: true
  9734. });
  9735. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9736. /** Gets or sets minimum value */
  9737. get: function () {
  9738. return this._minimum;
  9739. },
  9740. set: function (value) {
  9741. if (this._minimum === value) {
  9742. return;
  9743. }
  9744. this._minimum = value;
  9745. this._markAsDirty();
  9746. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9747. },
  9748. enumerable: true,
  9749. configurable: true
  9750. });
  9751. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9752. /** Gets or sets maximum value */
  9753. get: function () {
  9754. return this._maximum;
  9755. },
  9756. set: function (value) {
  9757. if (this._maximum === value) {
  9758. return;
  9759. }
  9760. this._maximum = value;
  9761. this._markAsDirty();
  9762. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9763. },
  9764. enumerable: true,
  9765. configurable: true
  9766. });
  9767. Object.defineProperty(BaseSlider.prototype, "value", {
  9768. /** Gets or sets current value */
  9769. get: function () {
  9770. return this._value;
  9771. },
  9772. set: function (value) {
  9773. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9774. if (this._value === value) {
  9775. return;
  9776. }
  9777. this._value = value;
  9778. this._markAsDirty();
  9779. this.onValueChangedObservable.notifyObservers(this._value);
  9780. },
  9781. enumerable: true,
  9782. configurable: true
  9783. });
  9784. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9785. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9786. get: function () {
  9787. return this._isVertical;
  9788. },
  9789. set: function (value) {
  9790. if (this._isVertical === value) {
  9791. return;
  9792. }
  9793. this._isVertical = value;
  9794. this._markAsDirty();
  9795. },
  9796. enumerable: true,
  9797. configurable: true
  9798. });
  9799. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9800. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9801. get: function () {
  9802. return this._isThumbClamped;
  9803. },
  9804. set: function (value) {
  9805. if (this._isThumbClamped === value) {
  9806. return;
  9807. }
  9808. this._isThumbClamped = value;
  9809. this._markAsDirty();
  9810. },
  9811. enumerable: true,
  9812. configurable: true
  9813. });
  9814. BaseSlider.prototype._getTypeName = function () {
  9815. return "BaseSlider";
  9816. };
  9817. BaseSlider.prototype._getThumbPosition = function () {
  9818. if (this.isVertical) {
  9819. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9820. }
  9821. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9822. };
  9823. BaseSlider.prototype._getThumbThickness = function (type) {
  9824. var thumbThickness = 0;
  9825. switch (type) {
  9826. case "circle":
  9827. if (this._thumbWidth.isPixel) {
  9828. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9829. }
  9830. else {
  9831. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9832. }
  9833. break;
  9834. case "rectangle":
  9835. if (this._thumbWidth.isPixel) {
  9836. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9837. }
  9838. else {
  9839. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9840. }
  9841. }
  9842. return thumbThickness;
  9843. };
  9844. BaseSlider.prototype._prepareRenderingData = function (type) {
  9845. // Main bar
  9846. this._effectiveBarOffset = 0;
  9847. this._renderLeft = this._currentMeasure.left;
  9848. this._renderTop = this._currentMeasure.top;
  9849. this._renderWidth = this._currentMeasure.width;
  9850. this._renderHeight = this._currentMeasure.height;
  9851. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9852. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9853. this._effectiveThumbThickness = this._getThumbThickness(type);
  9854. if (this.displayThumb) {
  9855. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9856. }
  9857. //throw error when height is less than width for vertical slider
  9858. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9859. console.error("Height should be greater than width");
  9860. return;
  9861. }
  9862. if (this._barOffset.isPixel) {
  9863. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9864. }
  9865. else {
  9866. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9867. }
  9868. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9869. if (this.isVertical) {
  9870. this._renderLeft += this._effectiveBarOffset;
  9871. if (!this.isThumbClamped && this.displayThumb) {
  9872. this._renderTop += (this._effectiveThumbThickness / 2);
  9873. }
  9874. this._renderHeight = this._backgroundBoxLength;
  9875. this._renderWidth = this._backgroundBoxThickness;
  9876. }
  9877. else {
  9878. this._renderTop += this._effectiveBarOffset;
  9879. if (!this.isThumbClamped && this.displayThumb) {
  9880. this._renderLeft += (this._effectiveThumbThickness / 2);
  9881. }
  9882. this._renderHeight = this._backgroundBoxThickness;
  9883. this._renderWidth = this._backgroundBoxLength;
  9884. }
  9885. };
  9886. /** @hidden */
  9887. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9888. if (this.rotation != 0) {
  9889. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9890. x = this._transformedPosition.x;
  9891. y = this._transformedPosition.y;
  9892. }
  9893. if (this._isVertical) {
  9894. this.value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9895. }
  9896. else {
  9897. this.value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9898. }
  9899. };
  9900. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  9901. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  9902. return false;
  9903. }
  9904. this._pointerIsDown = true;
  9905. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9906. this._host._capturingControl[pointerId] = this;
  9907. return true;
  9908. };
  9909. BaseSlider.prototype._onPointerMove = function (target, coordinates) {
  9910. if (this._pointerIsDown) {
  9911. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9912. }
  9913. _super.prototype._onPointerMove.call(this, target, coordinates);
  9914. };
  9915. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  9916. this._pointerIsDown = false;
  9917. delete this._host._capturingControl[pointerId];
  9918. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  9919. };
  9920. return BaseSlider;
  9921. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9922. /***/ }),
  9923. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  9924. /*!*************************************************!*\
  9925. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  9926. \*************************************************/
  9927. /*! exports provided: ImageBasedSlider */
  9928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9929. "use strict";
  9930. __webpack_require__.r(__webpack_exports__);
  9931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  9932. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9933. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  9934. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9935. /**
  9936. * Class used to create slider controls based on images
  9937. */
  9938. var ImageBasedSlider = /** @class */ (function (_super) {
  9939. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  9940. /**
  9941. * Creates a new ImageBasedSlider
  9942. * @param name defines the control name
  9943. */
  9944. function ImageBasedSlider(name) {
  9945. var _this = _super.call(this, name) || this;
  9946. _this.name = name;
  9947. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  9948. return _this;
  9949. }
  9950. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  9951. get: function () {
  9952. return this._displayThumb && this.thumbImage != null;
  9953. },
  9954. set: function (value) {
  9955. if (this._displayThumb === value) {
  9956. return;
  9957. }
  9958. this._displayThumb = value;
  9959. this._markAsDirty();
  9960. },
  9961. enumerable: true,
  9962. configurable: true
  9963. });
  9964. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  9965. /**
  9966. * Gets or sets the image used to render the background
  9967. */
  9968. get: function () {
  9969. return this._backgroundImage;
  9970. },
  9971. set: function (value) {
  9972. var _this = this;
  9973. if (this._backgroundImage === value) {
  9974. return;
  9975. }
  9976. this._backgroundImage = value;
  9977. if (value && !value.isLoaded) {
  9978. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  9979. }
  9980. this._markAsDirty();
  9981. },
  9982. enumerable: true,
  9983. configurable: true
  9984. });
  9985. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  9986. /**
  9987. * Gets or sets the image used to render the value bar
  9988. */
  9989. get: function () {
  9990. return this._valueBarImage;
  9991. },
  9992. set: function (value) {
  9993. var _this = this;
  9994. if (this._valueBarImage === value) {
  9995. return;
  9996. }
  9997. this._valueBarImage = value;
  9998. if (value && !value.isLoaded) {
  9999. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10000. }
  10001. this._markAsDirty();
  10002. },
  10003. enumerable: true,
  10004. configurable: true
  10005. });
  10006. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10007. /**
  10008. * Gets or sets the image used to render the thumb
  10009. */
  10010. get: function () {
  10011. return this._thumbImage;
  10012. },
  10013. set: function (value) {
  10014. var _this = this;
  10015. if (this._thumbImage === value) {
  10016. return;
  10017. }
  10018. this._thumbImage = value;
  10019. if (value && !value.isLoaded) {
  10020. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10021. }
  10022. this._markAsDirty();
  10023. },
  10024. enumerable: true,
  10025. configurable: true
  10026. });
  10027. ImageBasedSlider.prototype._getTypeName = function () {
  10028. return "ImageBasedSlider";
  10029. };
  10030. ImageBasedSlider.prototype._draw = function (context) {
  10031. context.save();
  10032. this._applyStates(context);
  10033. this._prepareRenderingData("rectangle");
  10034. var thumbPosition = this._getThumbPosition();
  10035. var left = this._renderLeft;
  10036. var top = this._renderTop;
  10037. var width = this._renderWidth;
  10038. var height = this._renderHeight;
  10039. // Background
  10040. if (this._backgroundImage) {
  10041. this._tempMeasure.copyFromFloats(left, top, width, height);
  10042. if (this.isThumbClamped && this.displayThumb) {
  10043. if (this.isVertical) {
  10044. this._tempMeasure.height += this._effectiveThumbThickness;
  10045. }
  10046. else {
  10047. this._tempMeasure.width += this._effectiveThumbThickness;
  10048. }
  10049. }
  10050. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10051. this._backgroundImage._draw(context);
  10052. }
  10053. // Bar
  10054. if (this._valueBarImage) {
  10055. if (this.isVertical) {
  10056. if (this.isThumbClamped && this.displayThumb) {
  10057. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10058. }
  10059. else {
  10060. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10061. }
  10062. }
  10063. else {
  10064. if (this.isThumbClamped && this.displayThumb) {
  10065. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10066. }
  10067. else {
  10068. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10069. }
  10070. }
  10071. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10072. this._valueBarImage._draw(context);
  10073. }
  10074. // Thumb
  10075. if (this.displayThumb) {
  10076. if (this.isVertical) {
  10077. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10078. }
  10079. else {
  10080. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10081. }
  10082. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10083. this._thumbImage._draw(context);
  10084. }
  10085. context.restore();
  10086. };
  10087. return ImageBasedSlider;
  10088. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10089. /***/ }),
  10090. /***/ "./2D/controls/sliders/scrollBar.ts":
  10091. /*!******************************************!*\
  10092. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10093. \******************************************/
  10094. /*! exports provided: ScrollBar */
  10095. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10096. "use strict";
  10097. __webpack_require__.r(__webpack_exports__);
  10098. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10099. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10100. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10101. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10102. /**
  10103. * Class used to create slider controls
  10104. */
  10105. var ScrollBar = /** @class */ (function (_super) {
  10106. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10107. /**
  10108. * Creates a new Slider
  10109. * @param name defines the control name
  10110. */
  10111. function ScrollBar(name) {
  10112. var _this = _super.call(this, name) || this;
  10113. _this.name = name;
  10114. _this._background = "black";
  10115. _this._borderColor = "white";
  10116. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10117. return _this;
  10118. }
  10119. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10120. /** Gets or sets border color */
  10121. get: function () {
  10122. return this._borderColor;
  10123. },
  10124. set: function (value) {
  10125. if (this._borderColor === value) {
  10126. return;
  10127. }
  10128. this._borderColor = value;
  10129. this._markAsDirty();
  10130. },
  10131. enumerable: true,
  10132. configurable: true
  10133. });
  10134. Object.defineProperty(ScrollBar.prototype, "background", {
  10135. /** Gets or sets background color */
  10136. get: function () {
  10137. return this._background;
  10138. },
  10139. set: function (value) {
  10140. if (this._background === value) {
  10141. return;
  10142. }
  10143. this._background = value;
  10144. this._markAsDirty();
  10145. },
  10146. enumerable: true,
  10147. configurable: true
  10148. });
  10149. ScrollBar.prototype._getTypeName = function () {
  10150. return "Scrollbar";
  10151. };
  10152. ScrollBar.prototype._getThumbThickness = function () {
  10153. var thumbThickness = 0;
  10154. if (this._thumbWidth.isPixel) {
  10155. thumbThickness = this._thumbWidth.getValue(this._host);
  10156. }
  10157. else {
  10158. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10159. }
  10160. return thumbThickness;
  10161. };
  10162. ScrollBar.prototype._draw = function (context) {
  10163. context.save();
  10164. this._applyStates(context);
  10165. this._prepareRenderingData("rectangle");
  10166. var left = this._renderLeft;
  10167. var thumbPosition = this._getThumbPosition();
  10168. context.fillStyle = this._background;
  10169. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10170. // Value bar
  10171. context.fillStyle = this.color;
  10172. // Thumb
  10173. if (this.isVertical) {
  10174. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10175. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10176. this._thumbMeasure.width = this._currentMeasure.width;
  10177. this._thumbMeasure.height = this._effectiveThumbThickness;
  10178. }
  10179. else {
  10180. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10181. this._thumbMeasure.top = this._currentMeasure.top;
  10182. this._thumbMeasure.width = this._effectiveThumbThickness;
  10183. this._thumbMeasure.height = this._currentMeasure.height;
  10184. }
  10185. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10186. context.restore();
  10187. };
  10188. /** @hidden */
  10189. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10190. if (this.rotation != 0) {
  10191. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10192. x = this._transformedPosition.x;
  10193. y = this._transformedPosition.y;
  10194. }
  10195. if (this._first) {
  10196. this._first = false;
  10197. this._originX = x;
  10198. this._originY = y;
  10199. // Check if move is required
  10200. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10201. if (this.isVertical) {
  10202. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10203. }
  10204. else {
  10205. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10206. }
  10207. }
  10208. }
  10209. // Delta mode
  10210. var delta = 0;
  10211. if (this.isVertical) {
  10212. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10213. }
  10214. else {
  10215. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10216. }
  10217. this.value += delta * (this.maximum - this.minimum);
  10218. this._originX = x;
  10219. this._originY = y;
  10220. };
  10221. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10222. this._first = true;
  10223. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10224. };
  10225. return ScrollBar;
  10226. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10227. /***/ }),
  10228. /***/ "./2D/controls/sliders/slider.ts":
  10229. /*!***************************************!*\
  10230. !*** ./2D/controls/sliders/slider.ts ***!
  10231. \***************************************/
  10232. /*! exports provided: Slider */
  10233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10234. "use strict";
  10235. __webpack_require__.r(__webpack_exports__);
  10236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10237. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10238. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10239. /**
  10240. * Class used to create slider controls
  10241. */
  10242. var Slider = /** @class */ (function (_super) {
  10243. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10244. /**
  10245. * Creates a new Slider
  10246. * @param name defines the control name
  10247. */
  10248. function Slider(name) {
  10249. var _this = _super.call(this, name) || this;
  10250. _this.name = name;
  10251. _this._background = "black";
  10252. _this._borderColor = "white";
  10253. _this._isThumbCircle = false;
  10254. _this._displayValueBar = true;
  10255. return _this;
  10256. }
  10257. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10258. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10259. get: function () {
  10260. return this._displayValueBar;
  10261. },
  10262. set: function (value) {
  10263. if (this._displayValueBar === value) {
  10264. return;
  10265. }
  10266. this._displayValueBar = value;
  10267. this._markAsDirty();
  10268. },
  10269. enumerable: true,
  10270. configurable: true
  10271. });
  10272. Object.defineProperty(Slider.prototype, "borderColor", {
  10273. /** Gets or sets border color */
  10274. get: function () {
  10275. return this._borderColor;
  10276. },
  10277. set: function (value) {
  10278. if (this._borderColor === value) {
  10279. return;
  10280. }
  10281. this._borderColor = value;
  10282. this._markAsDirty();
  10283. },
  10284. enumerable: true,
  10285. configurable: true
  10286. });
  10287. Object.defineProperty(Slider.prototype, "background", {
  10288. /** Gets or sets background color */
  10289. get: function () {
  10290. return this._background;
  10291. },
  10292. set: function (value) {
  10293. if (this._background === value) {
  10294. return;
  10295. }
  10296. this._background = value;
  10297. this._markAsDirty();
  10298. },
  10299. enumerable: true,
  10300. configurable: true
  10301. });
  10302. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10303. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10304. get: function () {
  10305. return this._isThumbCircle;
  10306. },
  10307. set: function (value) {
  10308. if (this._isThumbCircle === value) {
  10309. return;
  10310. }
  10311. this._isThumbCircle = value;
  10312. this._markAsDirty();
  10313. },
  10314. enumerable: true,
  10315. configurable: true
  10316. });
  10317. Slider.prototype._getTypeName = function () {
  10318. return "Slider";
  10319. };
  10320. Slider.prototype._draw = function (context) {
  10321. context.save();
  10322. this._applyStates(context);
  10323. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10324. var left = this._renderLeft;
  10325. var top = this._renderTop;
  10326. var width = this._renderWidth;
  10327. var height = this._renderHeight;
  10328. var radius = 0;
  10329. if (this.isThumbClamped && this.isThumbCircle) {
  10330. if (this.isVertical) {
  10331. top += (this._effectiveThumbThickness / 2);
  10332. }
  10333. else {
  10334. left += (this._effectiveThumbThickness / 2);
  10335. }
  10336. radius = this._backgroundBoxThickness / 2;
  10337. }
  10338. else {
  10339. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10340. }
  10341. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10342. context.shadowColor = this.shadowColor;
  10343. context.shadowBlur = this.shadowBlur;
  10344. context.shadowOffsetX = this.shadowOffsetX;
  10345. context.shadowOffsetY = this.shadowOffsetY;
  10346. }
  10347. var thumbPosition = this._getThumbPosition();
  10348. context.fillStyle = this._background;
  10349. if (this.isVertical) {
  10350. if (this.isThumbClamped) {
  10351. if (this.isThumbCircle) {
  10352. context.beginPath();
  10353. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10354. context.fill();
  10355. context.fillRect(left, top, width, height);
  10356. }
  10357. else {
  10358. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10359. }
  10360. }
  10361. else {
  10362. context.fillRect(left, top, width, height);
  10363. }
  10364. }
  10365. else {
  10366. if (this.isThumbClamped) {
  10367. if (this.isThumbCircle) {
  10368. context.beginPath();
  10369. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10370. context.fill();
  10371. context.fillRect(left, top, width, height);
  10372. }
  10373. else {
  10374. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10375. }
  10376. }
  10377. else {
  10378. context.fillRect(left, top, width, height);
  10379. }
  10380. }
  10381. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10382. context.shadowBlur = 0;
  10383. context.shadowOffsetX = 0;
  10384. context.shadowOffsetY = 0;
  10385. }
  10386. // Value bar
  10387. context.fillStyle = this.color;
  10388. if (this._displayValueBar) {
  10389. if (this.isVertical) {
  10390. if (this.isThumbClamped) {
  10391. if (this.isThumbCircle) {
  10392. context.beginPath();
  10393. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10394. context.fill();
  10395. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10396. }
  10397. else {
  10398. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10399. }
  10400. }
  10401. else {
  10402. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10403. }
  10404. }
  10405. else {
  10406. if (this.isThumbClamped) {
  10407. if (this.isThumbCircle) {
  10408. context.beginPath();
  10409. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10410. context.fill();
  10411. context.fillRect(left, top, thumbPosition, height);
  10412. }
  10413. else {
  10414. context.fillRect(left, top, thumbPosition, height);
  10415. }
  10416. }
  10417. else {
  10418. context.fillRect(left, top, thumbPosition, height);
  10419. }
  10420. }
  10421. }
  10422. // Thumb
  10423. if (this.displayThumb) {
  10424. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10425. context.shadowColor = this.shadowColor;
  10426. context.shadowBlur = this.shadowBlur;
  10427. context.shadowOffsetX = this.shadowOffsetX;
  10428. context.shadowOffsetY = this.shadowOffsetY;
  10429. }
  10430. if (this._isThumbCircle) {
  10431. context.beginPath();
  10432. if (this.isVertical) {
  10433. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10434. }
  10435. else {
  10436. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10437. }
  10438. context.fill();
  10439. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10440. context.shadowBlur = 0;
  10441. context.shadowOffsetX = 0;
  10442. context.shadowOffsetY = 0;
  10443. }
  10444. context.strokeStyle = this._borderColor;
  10445. context.stroke();
  10446. }
  10447. else {
  10448. if (this.isVertical) {
  10449. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10450. }
  10451. else {
  10452. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10453. }
  10454. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10455. context.shadowBlur = 0;
  10456. context.shadowOffsetX = 0;
  10457. context.shadowOffsetY = 0;
  10458. }
  10459. context.strokeStyle = this._borderColor;
  10460. if (this.isVertical) {
  10461. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10462. }
  10463. else {
  10464. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10465. }
  10466. }
  10467. }
  10468. context.restore();
  10469. };
  10470. return Slider;
  10471. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10472. /***/ }),
  10473. /***/ "./2D/controls/stackPanel.ts":
  10474. /*!***********************************!*\
  10475. !*** ./2D/controls/stackPanel.ts ***!
  10476. \***********************************/
  10477. /*! exports provided: StackPanel */
  10478. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10479. "use strict";
  10480. __webpack_require__.r(__webpack_exports__);
  10481. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10482. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10483. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  10484. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10485. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10486. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10487. /**
  10488. * Class used to create a 2D stack panel container
  10489. */
  10490. var StackPanel = /** @class */ (function (_super) {
  10491. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10492. /**
  10493. * Creates a new StackPanel
  10494. * @param name defines control name
  10495. */
  10496. function StackPanel(name) {
  10497. var _this = _super.call(this, name) || this;
  10498. _this.name = name;
  10499. _this._isVertical = true;
  10500. _this._manualWidth = false;
  10501. _this._manualHeight = false;
  10502. _this._doNotTrackManualChanges = false;
  10503. return _this;
  10504. }
  10505. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10506. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10507. get: function () {
  10508. return this._isVertical;
  10509. },
  10510. set: function (value) {
  10511. if (this._isVertical === value) {
  10512. return;
  10513. }
  10514. this._isVertical = value;
  10515. this._markAsDirty();
  10516. },
  10517. enumerable: true,
  10518. configurable: true
  10519. });
  10520. Object.defineProperty(StackPanel.prototype, "width", {
  10521. get: function () {
  10522. return this._width.toString(this._host);
  10523. },
  10524. /**
  10525. * Gets or sets panel width.
  10526. * This value should not be set when in horizontal mode as it will be computed automatically
  10527. */
  10528. set: function (value) {
  10529. if (!this._doNotTrackManualChanges) {
  10530. this._manualWidth = true;
  10531. }
  10532. if (this._width.toString(this._host) === value) {
  10533. return;
  10534. }
  10535. if (this._width.fromString(value)) {
  10536. this._markAsDirty();
  10537. }
  10538. },
  10539. enumerable: true,
  10540. configurable: true
  10541. });
  10542. Object.defineProperty(StackPanel.prototype, "height", {
  10543. get: function () {
  10544. return this._height.toString(this._host);
  10545. },
  10546. /**
  10547. * Gets or sets panel height.
  10548. * This value should not be set when in vertical mode as it will be computed automatically
  10549. */
  10550. set: function (value) {
  10551. if (!this._doNotTrackManualChanges) {
  10552. this._manualHeight = true;
  10553. }
  10554. if (this._height.toString(this._host) === value) {
  10555. return;
  10556. }
  10557. if (this._height.fromString(value)) {
  10558. this._markAsDirty();
  10559. }
  10560. },
  10561. enumerable: true,
  10562. configurable: true
  10563. });
  10564. StackPanel.prototype._getTypeName = function () {
  10565. return "StackPanel";
  10566. };
  10567. /** @hidden */
  10568. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10569. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10570. var child = _a[_i];
  10571. if (this._isVertical) {
  10572. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10573. }
  10574. else {
  10575. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10576. }
  10577. }
  10578. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10579. };
  10580. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10581. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10582. this._measureForChildren.copyFrom(parentMeasure);
  10583. this._measureForChildren.left = this._currentMeasure.left;
  10584. this._measureForChildren.top = this._currentMeasure.top;
  10585. if (!this.isVertical || this._manualWidth) {
  10586. this._measureForChildren.width = this._currentMeasure.width;
  10587. }
  10588. if (this.isVertical || this._manualHeight) {
  10589. this._measureForChildren.height = this._currentMeasure.height;
  10590. }
  10591. };
  10592. StackPanel.prototype._postMeasure = function () {
  10593. var stackWidth = 0;
  10594. var stackHeight = 0;
  10595. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10596. var child = _a[_i];
  10597. if (!child.isVisible || child.notRenderable) {
  10598. continue;
  10599. }
  10600. if (this._isVertical) {
  10601. if (child.top !== stackHeight + "px") {
  10602. child.top = stackHeight + "px";
  10603. this._rebuildLayout = true;
  10604. child._top.ignoreAdaptiveScaling = true;
  10605. }
  10606. if (child._height.isPercentage) {
  10607. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Control (Name:" + child.name + ", UniqueId:" + child.uniqueId + ") is using height in percentage mode inside a vertical StackPanel");
  10608. }
  10609. else {
  10610. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10611. }
  10612. }
  10613. else {
  10614. if (child.left !== stackWidth + "px") {
  10615. child.left = stackWidth + "px";
  10616. this._rebuildLayout = true;
  10617. child._left.ignoreAdaptiveScaling = true;
  10618. }
  10619. if (child._width.isPercentage) {
  10620. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Control (Name:" + child.name + ", UniqueId:" + child.uniqueId + ") is using width in percentage mode inside a horizontal StackPanel");
  10621. }
  10622. else {
  10623. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10624. }
  10625. }
  10626. }
  10627. this._doNotTrackManualChanges = true;
  10628. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10629. // User can now define their own height and width for stack panel.
  10630. var panelWidthChanged = false;
  10631. var panelHeightChanged = false;
  10632. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10633. var previousHeight = this.height;
  10634. this.height = stackHeight + "px";
  10635. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10636. }
  10637. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10638. var previousWidth = this.width;
  10639. this.width = stackWidth + "px";
  10640. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10641. }
  10642. if (panelHeightChanged) {
  10643. this._height.ignoreAdaptiveScaling = true;
  10644. }
  10645. if (panelWidthChanged) {
  10646. this._width.ignoreAdaptiveScaling = true;
  10647. }
  10648. this._doNotTrackManualChanges = false;
  10649. if (panelWidthChanged || panelHeightChanged) {
  10650. this._rebuildLayout = true;
  10651. }
  10652. _super.prototype._postMeasure.call(this);
  10653. };
  10654. return StackPanel;
  10655. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10656. /***/ }),
  10657. /***/ "./2D/controls/statics.ts":
  10658. /*!********************************!*\
  10659. !*** ./2D/controls/statics.ts ***!
  10660. \********************************/
  10661. /*! exports provided: name */
  10662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10663. "use strict";
  10664. __webpack_require__.r(__webpack_exports__);
  10665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10666. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10667. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10668. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10669. /**
  10670. * Forcing an export so that this code will execute
  10671. * @hidden
  10672. */
  10673. var name = "Statics";
  10674. /**
  10675. * Creates a stack panel that can be used to render headers
  10676. * @param control defines the control to associate with the header
  10677. * @param text defines the text of the header
  10678. * @param size defines the size of the header
  10679. * @param options defines options used to configure the header
  10680. * @returns a new StackPanel
  10681. */
  10682. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10683. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10684. var isHorizontal = options ? options.isHorizontal : true;
  10685. var controlFirst = options ? options.controlFirst : true;
  10686. panel.isVertical = !isHorizontal;
  10687. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10688. header.text = text;
  10689. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10690. if (isHorizontal) {
  10691. header.width = size;
  10692. }
  10693. else {
  10694. header.height = size;
  10695. }
  10696. if (controlFirst) {
  10697. panel.addControl(control);
  10698. panel.addControl(header);
  10699. header.paddingLeft = "5px";
  10700. }
  10701. else {
  10702. panel.addControl(header);
  10703. panel.addControl(control);
  10704. header.paddingRight = "5px";
  10705. }
  10706. header.shadowBlur = control.shadowBlur;
  10707. header.shadowColor = control.shadowColor;
  10708. header.shadowOffsetX = control.shadowOffsetX;
  10709. header.shadowOffsetY = control.shadowOffsetY;
  10710. return panel;
  10711. };
  10712. /***/ }),
  10713. /***/ "./2D/controls/textBlock.ts":
  10714. /*!**********************************!*\
  10715. !*** ./2D/controls/textBlock.ts ***!
  10716. \**********************************/
  10717. /*! exports provided: TextWrapping, TextBlock */
  10718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10719. "use strict";
  10720. __webpack_require__.r(__webpack_exports__);
  10721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10723. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10724. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  10725. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10726. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10727. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10728. /**
  10729. * Enum that determines the text-wrapping mode to use.
  10730. */
  10731. var TextWrapping;
  10732. (function (TextWrapping) {
  10733. /**
  10734. * Clip the text when it's larger than Control.width; this is the default mode.
  10735. */
  10736. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10737. /**
  10738. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10739. */
  10740. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10741. /**
  10742. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10743. */
  10744. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10745. })(TextWrapping || (TextWrapping = {}));
  10746. /**
  10747. * Class used to create text block control
  10748. */
  10749. var TextBlock = /** @class */ (function (_super) {
  10750. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10751. /**
  10752. * Creates a new TextBlock object
  10753. * @param name defines the name of the control
  10754. * @param text defines the text to display (emptry string by default)
  10755. */
  10756. function TextBlock(
  10757. /**
  10758. * Defines the name of the control
  10759. */
  10760. name, text) {
  10761. if (text === void 0) { text = ""; }
  10762. var _this = _super.call(this, name) || this;
  10763. _this.name = name;
  10764. _this._text = "";
  10765. _this._textWrapping = TextWrapping.Clip;
  10766. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10767. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10768. _this._resizeToFit = false;
  10769. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10770. _this._outlineWidth = 0;
  10771. _this._outlineColor = "white";
  10772. /**
  10773. * An event triggered after the text is changed
  10774. */
  10775. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10776. /**
  10777. * An event triggered after the text was broken up into lines
  10778. */
  10779. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10780. _this.text = text;
  10781. return _this;
  10782. }
  10783. Object.defineProperty(TextBlock.prototype, "lines", {
  10784. /**
  10785. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10786. */
  10787. get: function () {
  10788. return this._lines;
  10789. },
  10790. enumerable: true,
  10791. configurable: true
  10792. });
  10793. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10794. /**
  10795. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10796. */
  10797. get: function () {
  10798. return this._resizeToFit;
  10799. },
  10800. /**
  10801. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10802. */
  10803. set: function (value) {
  10804. if (this._resizeToFit === value) {
  10805. return;
  10806. }
  10807. this._resizeToFit = value;
  10808. if (this._resizeToFit) {
  10809. this._width.ignoreAdaptiveScaling = true;
  10810. this._height.ignoreAdaptiveScaling = true;
  10811. }
  10812. this._markAsDirty();
  10813. },
  10814. enumerable: true,
  10815. configurable: true
  10816. });
  10817. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10818. /**
  10819. * Gets or sets a boolean indicating if text must be wrapped
  10820. */
  10821. get: function () {
  10822. return this._textWrapping;
  10823. },
  10824. /**
  10825. * Gets or sets a boolean indicating if text must be wrapped
  10826. */
  10827. set: function (value) {
  10828. if (this._textWrapping === value) {
  10829. return;
  10830. }
  10831. this._textWrapping = +value;
  10832. this._markAsDirty();
  10833. },
  10834. enumerable: true,
  10835. configurable: true
  10836. });
  10837. Object.defineProperty(TextBlock.prototype, "text", {
  10838. /**
  10839. * Gets or sets text to display
  10840. */
  10841. get: function () {
  10842. return this._text;
  10843. },
  10844. /**
  10845. * Gets or sets text to display
  10846. */
  10847. set: function (value) {
  10848. if (this._text === value) {
  10849. return;
  10850. }
  10851. this._text = value;
  10852. this._markAsDirty();
  10853. this.onTextChangedObservable.notifyObservers(this);
  10854. },
  10855. enumerable: true,
  10856. configurable: true
  10857. });
  10858. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10859. /**
  10860. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10861. */
  10862. get: function () {
  10863. return this._textHorizontalAlignment;
  10864. },
  10865. /**
  10866. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10867. */
  10868. set: function (value) {
  10869. if (this._textHorizontalAlignment === value) {
  10870. return;
  10871. }
  10872. this._textHorizontalAlignment = value;
  10873. this._markAsDirty();
  10874. },
  10875. enumerable: true,
  10876. configurable: true
  10877. });
  10878. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10879. /**
  10880. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10881. */
  10882. get: function () {
  10883. return this._textVerticalAlignment;
  10884. },
  10885. /**
  10886. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10887. */
  10888. set: function (value) {
  10889. if (this._textVerticalAlignment === value) {
  10890. return;
  10891. }
  10892. this._textVerticalAlignment = value;
  10893. this._markAsDirty();
  10894. },
  10895. enumerable: true,
  10896. configurable: true
  10897. });
  10898. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  10899. /**
  10900. * Gets or sets line spacing value
  10901. */
  10902. get: function () {
  10903. return this._lineSpacing.toString(this._host);
  10904. },
  10905. /**
  10906. * Gets or sets line spacing value
  10907. */
  10908. set: function (value) {
  10909. if (this._lineSpacing.fromString(value)) {
  10910. this._markAsDirty();
  10911. }
  10912. },
  10913. enumerable: true,
  10914. configurable: true
  10915. });
  10916. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  10917. /**
  10918. * Gets or sets outlineWidth of the text to display
  10919. */
  10920. get: function () {
  10921. return this._outlineWidth;
  10922. },
  10923. /**
  10924. * Gets or sets outlineWidth of the text to display
  10925. */
  10926. set: function (value) {
  10927. if (this._outlineWidth === value) {
  10928. return;
  10929. }
  10930. this._outlineWidth = value;
  10931. this._markAsDirty();
  10932. },
  10933. enumerable: true,
  10934. configurable: true
  10935. });
  10936. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  10937. /**
  10938. * Gets or sets outlineColor of the text to display
  10939. */
  10940. get: function () {
  10941. return this._outlineColor;
  10942. },
  10943. /**
  10944. * Gets or sets outlineColor of the text to display
  10945. */
  10946. set: function (value) {
  10947. if (this._outlineColor === value) {
  10948. return;
  10949. }
  10950. this._outlineColor = value;
  10951. this._markAsDirty();
  10952. },
  10953. enumerable: true,
  10954. configurable: true
  10955. });
  10956. TextBlock.prototype._getTypeName = function () {
  10957. return "TextBlock";
  10958. };
  10959. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  10960. if (!this._fontOffset) {
  10961. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  10962. }
  10963. _super.prototype._processMeasures.call(this, parentMeasure, context);
  10964. // Prepare lines
  10965. this._lines = this._breakLines(this._currentMeasure.width, context);
  10966. this.onLinesReadyObservable.notifyObservers(this);
  10967. var maxLineWidth = 0;
  10968. for (var i = 0; i < this._lines.length; i++) {
  10969. var line = this._lines[i];
  10970. if (line.width > maxLineWidth) {
  10971. maxLineWidth = line.width;
  10972. }
  10973. }
  10974. if (this._resizeToFit) {
  10975. if (this._textWrapping === TextWrapping.Clip) {
  10976. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  10977. if (newWidth !== this._width.internalValue) {
  10978. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  10979. this._rebuildLayout = true;
  10980. }
  10981. }
  10982. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  10983. if (newHeight !== this._height.internalValue) {
  10984. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  10985. this._rebuildLayout = true;
  10986. }
  10987. }
  10988. };
  10989. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  10990. var width = this._currentMeasure.width;
  10991. var x = 0;
  10992. switch (this._textHorizontalAlignment) {
  10993. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  10994. x = 0;
  10995. break;
  10996. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  10997. x = width - textWidth;
  10998. break;
  10999. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11000. x = (width - textWidth) / 2;
  11001. break;
  11002. }
  11003. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11004. context.shadowColor = this.shadowColor;
  11005. context.shadowBlur = this.shadowBlur;
  11006. context.shadowOffsetX = this.shadowOffsetX;
  11007. context.shadowOffsetY = this.shadowOffsetY;
  11008. }
  11009. if (this.outlineWidth) {
  11010. context.strokeText(text, this._currentMeasure.left + x, y);
  11011. }
  11012. context.fillText(text, this._currentMeasure.left + x, y);
  11013. };
  11014. /** @hidden */
  11015. TextBlock.prototype._draw = function (context) {
  11016. context.save();
  11017. this._applyStates(context);
  11018. // Render lines
  11019. this._renderLines(context);
  11020. context.restore();
  11021. };
  11022. TextBlock.prototype._applyStates = function (context) {
  11023. _super.prototype._applyStates.call(this, context);
  11024. if (this.outlineWidth) {
  11025. context.lineWidth = this.outlineWidth;
  11026. context.strokeStyle = this.outlineColor;
  11027. }
  11028. };
  11029. TextBlock.prototype._breakLines = function (refWidth, context) {
  11030. var lines = [];
  11031. var _lines = this.text.split("\n");
  11032. if (this._textWrapping === TextWrapping.Ellipsis) {
  11033. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11034. var _line = _lines_1[_i];
  11035. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11036. }
  11037. }
  11038. else if (this._textWrapping === TextWrapping.WordWrap) {
  11039. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11040. var _line = _lines_2[_a];
  11041. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11042. }
  11043. }
  11044. else {
  11045. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11046. var _line = _lines_3[_b];
  11047. lines.push(this._parseLine(_line, context));
  11048. }
  11049. }
  11050. return lines;
  11051. };
  11052. TextBlock.prototype._parseLine = function (line, context) {
  11053. if (line === void 0) { line = ''; }
  11054. return { text: line, width: context.measureText(line).width };
  11055. };
  11056. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11057. if (line === void 0) { line = ''; }
  11058. var lineWidth = context.measureText(line).width;
  11059. if (lineWidth > width) {
  11060. line += '…';
  11061. }
  11062. while (line.length > 2 && lineWidth > width) {
  11063. line = line.slice(0, -2) + '…';
  11064. lineWidth = context.measureText(line).width;
  11065. }
  11066. return { text: line, width: lineWidth };
  11067. };
  11068. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11069. if (line === void 0) { line = ''; }
  11070. var lines = [];
  11071. var words = line.split(' ');
  11072. var lineWidth = 0;
  11073. for (var n = 0; n < words.length; n++) {
  11074. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11075. var metrics = context.measureText(testLine);
  11076. var testWidth = metrics.width;
  11077. if (testWidth > width && n > 0) {
  11078. lines.push({ text: line, width: lineWidth });
  11079. line = words[n];
  11080. lineWidth = context.measureText(line).width;
  11081. }
  11082. else {
  11083. lineWidth = testWidth;
  11084. line = testLine;
  11085. }
  11086. }
  11087. lines.push({ text: line, width: lineWidth });
  11088. return lines;
  11089. };
  11090. TextBlock.prototype._renderLines = function (context) {
  11091. var height = this._currentMeasure.height;
  11092. var rootY = 0;
  11093. switch (this._textVerticalAlignment) {
  11094. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11095. rootY = this._fontOffset.ascent;
  11096. break;
  11097. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11098. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11099. break;
  11100. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11101. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11102. break;
  11103. }
  11104. rootY += this._currentMeasure.top;
  11105. for (var i = 0; i < this._lines.length; i++) {
  11106. var line = this._lines[i];
  11107. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11108. if (this._lineSpacing.isPixel) {
  11109. rootY += this._lineSpacing.getValue(this._host);
  11110. }
  11111. else {
  11112. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11113. }
  11114. }
  11115. this._drawText(line.text, line.width, rootY, context);
  11116. rootY += this._fontOffset.height;
  11117. }
  11118. };
  11119. /**
  11120. * Given a width constraint applied on the text block, find the expected height
  11121. * @returns expected height
  11122. */
  11123. TextBlock.prototype.computeExpectedHeight = function () {
  11124. if (this.text && this.widthInPixels) {
  11125. var context_1 = document.createElement('canvas').getContext('2d');
  11126. if (context_1) {
  11127. this._applyStates(context_1);
  11128. if (!this._fontOffset) {
  11129. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11130. }
  11131. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11132. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11133. }
  11134. }
  11135. return 0;
  11136. };
  11137. TextBlock.prototype.dispose = function () {
  11138. _super.prototype.dispose.call(this);
  11139. this.onTextChangedObservable.clear();
  11140. };
  11141. return TextBlock;
  11142. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11143. /***/ }),
  11144. /***/ "./2D/controls/virtualKeyboard.ts":
  11145. /*!****************************************!*\
  11146. !*** ./2D/controls/virtualKeyboard.ts ***!
  11147. \****************************************/
  11148. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11150. "use strict";
  11151. __webpack_require__.r(__webpack_exports__);
  11152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11153. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11154. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11155. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11156. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11157. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11158. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11159. /**
  11160. * Class used to store key control properties
  11161. */
  11162. var KeyPropertySet = /** @class */ (function () {
  11163. function KeyPropertySet() {
  11164. }
  11165. return KeyPropertySet;
  11166. }());
  11167. /**
  11168. * Class used to create virtual keyboard
  11169. */
  11170. var VirtualKeyboard = /** @class */ (function (_super) {
  11171. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11172. function VirtualKeyboard() {
  11173. var _this = _super !== null && _super.apply(this, arguments) || this;
  11174. /** Observable raised when a key is pressed */
  11175. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11176. /** Gets or sets default key button width */
  11177. _this.defaultButtonWidth = "40px";
  11178. /** Gets or sets default key button height */
  11179. _this.defaultButtonHeight = "40px";
  11180. /** Gets or sets default key button left padding */
  11181. _this.defaultButtonPaddingLeft = "2px";
  11182. /** Gets or sets default key button right padding */
  11183. _this.defaultButtonPaddingRight = "2px";
  11184. /** Gets or sets default key button top padding */
  11185. _this.defaultButtonPaddingTop = "2px";
  11186. /** Gets or sets default key button bottom padding */
  11187. _this.defaultButtonPaddingBottom = "2px";
  11188. /** Gets or sets default key button foreground color */
  11189. _this.defaultButtonColor = "#DDD";
  11190. /** Gets or sets default key button background color */
  11191. _this.defaultButtonBackground = "#070707";
  11192. /** Gets or sets shift button foreground color */
  11193. _this.shiftButtonColor = "#7799FF";
  11194. /** Gets or sets shift button thickness*/
  11195. _this.selectedShiftThickness = 1;
  11196. /** Gets shift key state */
  11197. _this.shiftState = 0;
  11198. _this._currentlyConnectedInputText = null;
  11199. _this._connectedInputTexts = [];
  11200. _this._onKeyPressObserver = null;
  11201. return _this;
  11202. }
  11203. VirtualKeyboard.prototype._getTypeName = function () {
  11204. return "VirtualKeyboard";
  11205. };
  11206. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11207. var _this = this;
  11208. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11209. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11210. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11211. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11212. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11213. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11214. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11215. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11216. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11217. button.thickness = 0;
  11218. button.isFocusInvisible = true;
  11219. button.shadowColor = this.shadowColor;
  11220. button.shadowBlur = this.shadowBlur;
  11221. button.shadowOffsetX = this.shadowOffsetX;
  11222. button.shadowOffsetY = this.shadowOffsetY;
  11223. button.onPointerUpObservable.add(function () {
  11224. _this.onKeyPressObservable.notifyObservers(key);
  11225. });
  11226. return button;
  11227. };
  11228. /**
  11229. * Adds a new row of keys
  11230. * @param keys defines the list of keys to add
  11231. * @param propertySets defines the associated property sets
  11232. */
  11233. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11234. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11235. panel.isVertical = false;
  11236. panel.isFocusInvisible = true;
  11237. for (var i = 0; i < keys.length; i++) {
  11238. var properties = null;
  11239. if (propertySets && propertySets.length === keys.length) {
  11240. properties = propertySets[i];
  11241. }
  11242. panel.addControl(this._createKey(keys[i], properties));
  11243. }
  11244. this.addControl(panel);
  11245. };
  11246. /**
  11247. * Set the shift key to a specific state
  11248. * @param shiftState defines the new shift state
  11249. */
  11250. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11251. if (!this.children) {
  11252. return;
  11253. }
  11254. for (var i = 0; i < this.children.length; i++) {
  11255. var row = this.children[i];
  11256. if (!row || !row.children) {
  11257. continue;
  11258. }
  11259. var rowContainer = row;
  11260. for (var j = 0; j < rowContainer.children.length; j++) {
  11261. var button = rowContainer.children[j];
  11262. if (!button || !button.children[0]) {
  11263. continue;
  11264. }
  11265. var button_tblock = button.children[0];
  11266. if (button_tblock.text === "\u21E7") {
  11267. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11268. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11269. }
  11270. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11271. }
  11272. }
  11273. };
  11274. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11275. /** Gets the input text control currently attached to the keyboard */
  11276. get: function () {
  11277. return this._currentlyConnectedInputText;
  11278. },
  11279. enumerable: true,
  11280. configurable: true
  11281. });
  11282. /**
  11283. * Connects the keyboard with an input text control
  11284. *
  11285. * @param input defines the target control
  11286. */
  11287. VirtualKeyboard.prototype.connect = function (input) {
  11288. var _this = this;
  11289. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11290. if (inputTextAlreadyConnected) {
  11291. return;
  11292. }
  11293. if (this._onKeyPressObserver === null) {
  11294. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11295. if (!_this._currentlyConnectedInputText) {
  11296. return;
  11297. }
  11298. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11299. switch (key) {
  11300. case "\u21E7":
  11301. _this.shiftState++;
  11302. if (_this.shiftState > 2) {
  11303. _this.shiftState = 0;
  11304. }
  11305. _this.applyShiftState(_this.shiftState);
  11306. return;
  11307. case "\u2190":
  11308. _this._currentlyConnectedInputText.processKey(8);
  11309. return;
  11310. case "\u21B5":
  11311. _this._currentlyConnectedInputText.processKey(13);
  11312. return;
  11313. }
  11314. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11315. if (_this.shiftState === 1) {
  11316. _this.shiftState = 0;
  11317. _this.applyShiftState(_this.shiftState);
  11318. }
  11319. });
  11320. }
  11321. this.isVisible = false;
  11322. this._currentlyConnectedInputText = input;
  11323. input._connectedVirtualKeyboard = this;
  11324. // Events hooking
  11325. var onFocusObserver = input.onFocusObservable.add(function () {
  11326. _this._currentlyConnectedInputText = input;
  11327. input._connectedVirtualKeyboard = _this;
  11328. _this.isVisible = true;
  11329. });
  11330. var onBlurObserver = input.onBlurObservable.add(function () {
  11331. input._connectedVirtualKeyboard = null;
  11332. _this._currentlyConnectedInputText = null;
  11333. _this.isVisible = false;
  11334. });
  11335. this._connectedInputTexts.push({
  11336. input: input,
  11337. onBlurObserver: onBlurObserver,
  11338. onFocusObserver: onFocusObserver
  11339. });
  11340. };
  11341. /**
  11342. * Disconnects the keyboard from connected InputText controls
  11343. *
  11344. * @param input optionally defines a target control, otherwise all are disconnected
  11345. */
  11346. VirtualKeyboard.prototype.disconnect = function (input) {
  11347. var _this = this;
  11348. if (input) {
  11349. // .find not available on IE
  11350. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11351. if (filtered.length === 1) {
  11352. this._removeConnectedInputObservables(filtered[0]);
  11353. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11354. if (this._currentlyConnectedInputText === input) {
  11355. this._currentlyConnectedInputText = null;
  11356. }
  11357. }
  11358. }
  11359. else {
  11360. this._connectedInputTexts.forEach(function (connectedInputText) {
  11361. _this._removeConnectedInputObservables(connectedInputText);
  11362. });
  11363. this._connectedInputTexts = [];
  11364. }
  11365. if (this._connectedInputTexts.length === 0) {
  11366. this._currentlyConnectedInputText = null;
  11367. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11368. this._onKeyPressObserver = null;
  11369. }
  11370. };
  11371. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11372. connectedInputText.input._connectedVirtualKeyboard = null;
  11373. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11374. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11375. };
  11376. /**
  11377. * Release all resources
  11378. */
  11379. VirtualKeyboard.prototype.dispose = function () {
  11380. _super.prototype.dispose.call(this);
  11381. this.disconnect();
  11382. };
  11383. // Statics
  11384. /**
  11385. * Creates a new keyboard using a default layout
  11386. *
  11387. * @param name defines control name
  11388. * @returns a new VirtualKeyboard
  11389. */
  11390. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11391. var returnValue = new VirtualKeyboard(name);
  11392. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11393. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11394. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11395. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11396. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11397. return returnValue;
  11398. };
  11399. return VirtualKeyboard;
  11400. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11401. /***/ }),
  11402. /***/ "./2D/index.ts":
  11403. /*!*********************!*\
  11404. !*** ./2D/index.ts ***!
  11405. \*********************/
  11406. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, name */
  11407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11408. "use strict";
  11409. __webpack_require__.r(__webpack_exports__);
  11410. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11441. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11443. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11445. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11448. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11450. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11452. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11454. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11456. /***/ }),
  11457. /***/ "./2D/math2D.ts":
  11458. /*!**********************!*\
  11459. !*** ./2D/math2D.ts ***!
  11460. \**********************/
  11461. /*! exports provided: Vector2WithInfo, Matrix2D */
  11462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11463. "use strict";
  11464. __webpack_require__.r(__webpack_exports__);
  11465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11467. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11468. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11469. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11470. /**
  11471. * Class used to transport Vector2 information for pointer events
  11472. */
  11473. var Vector2WithInfo = /** @class */ (function (_super) {
  11474. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11475. /**
  11476. * Creates a new Vector2WithInfo
  11477. * @param source defines the vector2 data to transport
  11478. * @param buttonIndex defines the current mouse button index
  11479. */
  11480. function Vector2WithInfo(source,
  11481. /** defines the current mouse button index */
  11482. buttonIndex) {
  11483. if (buttonIndex === void 0) { buttonIndex = 0; }
  11484. var _this = _super.call(this, source.x, source.y) || this;
  11485. _this.buttonIndex = buttonIndex;
  11486. return _this;
  11487. }
  11488. return Vector2WithInfo;
  11489. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11490. /** Class used to provide 2D matrix features */
  11491. var Matrix2D = /** @class */ (function () {
  11492. /**
  11493. * Creates a new matrix
  11494. * @param m00 defines value for (0, 0)
  11495. * @param m01 defines value for (0, 1)
  11496. * @param m10 defines value for (1, 0)
  11497. * @param m11 defines value for (1, 1)
  11498. * @param m20 defines value for (2, 0)
  11499. * @param m21 defines value for (2, 1)
  11500. */
  11501. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11502. /** Gets the internal array of 6 floats used to store matrix data */
  11503. this.m = new Float32Array(6);
  11504. this.fromValues(m00, m01, m10, m11, m20, m21);
  11505. }
  11506. /**
  11507. * Fills the matrix from direct values
  11508. * @param m00 defines value for (0, 0)
  11509. * @param m01 defines value for (0, 1)
  11510. * @param m10 defines value for (1, 0)
  11511. * @param m11 defines value for (1, 1)
  11512. * @param m20 defines value for (2, 0)
  11513. * @param m21 defines value for (2, 1)
  11514. * @returns the current modified matrix
  11515. */
  11516. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11517. this.m[0] = m00;
  11518. this.m[1] = m01;
  11519. this.m[2] = m10;
  11520. this.m[3] = m11;
  11521. this.m[4] = m20;
  11522. this.m[5] = m21;
  11523. return this;
  11524. };
  11525. /**
  11526. * Gets matrix determinant
  11527. * @returns the determinant
  11528. */
  11529. Matrix2D.prototype.determinant = function () {
  11530. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11531. };
  11532. /**
  11533. * Inverses the matrix and stores it in a target matrix
  11534. * @param result defines the target matrix
  11535. * @returns the current matrix
  11536. */
  11537. Matrix2D.prototype.invertToRef = function (result) {
  11538. var l0 = this.m[0];
  11539. var l1 = this.m[1];
  11540. var l2 = this.m[2];
  11541. var l3 = this.m[3];
  11542. var l4 = this.m[4];
  11543. var l5 = this.m[5];
  11544. var det = this.determinant();
  11545. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11546. result.m[0] = 0;
  11547. result.m[1] = 0;
  11548. result.m[2] = 0;
  11549. result.m[3] = 0;
  11550. result.m[4] = 0;
  11551. result.m[5] = 0;
  11552. return this;
  11553. }
  11554. var detDiv = 1 / det;
  11555. var det4 = l2 * l5 - l3 * l4;
  11556. var det5 = l1 * l4 - l0 * l5;
  11557. result.m[0] = l3 * detDiv;
  11558. result.m[1] = -l1 * detDiv;
  11559. result.m[2] = -l2 * detDiv;
  11560. result.m[3] = l0 * detDiv;
  11561. result.m[4] = det4 * detDiv;
  11562. result.m[5] = det5 * detDiv;
  11563. return this;
  11564. };
  11565. /**
  11566. * Multiplies the current matrix with another one
  11567. * @param other defines the second operand
  11568. * @param result defines the target matrix
  11569. * @returns the current matrix
  11570. */
  11571. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11572. var l0 = this.m[0];
  11573. var l1 = this.m[1];
  11574. var l2 = this.m[2];
  11575. var l3 = this.m[3];
  11576. var l4 = this.m[4];
  11577. var l5 = this.m[5];
  11578. var r0 = other.m[0];
  11579. var r1 = other.m[1];
  11580. var r2 = other.m[2];
  11581. var r3 = other.m[3];
  11582. var r4 = other.m[4];
  11583. var r5 = other.m[5];
  11584. result.m[0] = l0 * r0 + l1 * r2;
  11585. result.m[1] = l0 * r1 + l1 * r3;
  11586. result.m[2] = l2 * r0 + l3 * r2;
  11587. result.m[3] = l2 * r1 + l3 * r3;
  11588. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11589. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11590. return this;
  11591. };
  11592. /**
  11593. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11594. * @param x defines the x coordinate to transform
  11595. * @param y defines the x coordinate to transform
  11596. * @param result defines the target vector2
  11597. * @returns the current matrix
  11598. */
  11599. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11600. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11601. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11602. return this;
  11603. };
  11604. // Statics
  11605. /**
  11606. * Creates an identity matrix
  11607. * @returns a new matrix
  11608. */
  11609. Matrix2D.Identity = function () {
  11610. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11611. };
  11612. /**
  11613. * Creates a translation matrix and stores it in a target matrix
  11614. * @param x defines the x coordinate of the translation
  11615. * @param y defines the y coordinate of the translation
  11616. * @param result defines the target matrix
  11617. */
  11618. Matrix2D.TranslationToRef = function (x, y, result) {
  11619. result.fromValues(1, 0, 0, 1, x, y);
  11620. };
  11621. /**
  11622. * Creates a scaling matrix and stores it in a target matrix
  11623. * @param x defines the x coordinate of the scaling
  11624. * @param y defines the y coordinate of the scaling
  11625. * @param result defines the target matrix
  11626. */
  11627. Matrix2D.ScalingToRef = function (x, y, result) {
  11628. result.fromValues(x, 0, 0, y, 0, 0);
  11629. };
  11630. /**
  11631. * Creates a rotation matrix and stores it in a target matrix
  11632. * @param angle defines the rotation angle
  11633. * @param result defines the target matrix
  11634. */
  11635. Matrix2D.RotationToRef = function (angle, result) {
  11636. var s = Math.sin(angle);
  11637. var c = Math.cos(angle);
  11638. result.fromValues(c, s, -s, c, 0, 0);
  11639. };
  11640. /**
  11641. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11642. * @param tx defines the x coordinate of the translation
  11643. * @param ty defines the y coordinate of the translation
  11644. * @param angle defines the rotation angle
  11645. * @param scaleX defines the x coordinate of the scaling
  11646. * @param scaleY defines the y coordinate of the scaling
  11647. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11648. * @param result defines the target matrix
  11649. */
  11650. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11651. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11652. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11653. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11654. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11655. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11656. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11657. if (parentMatrix) {
  11658. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11659. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11660. }
  11661. else {
  11662. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11663. }
  11664. };
  11665. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11666. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11667. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11668. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11669. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11670. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11671. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11672. return Matrix2D;
  11673. }());
  11674. /***/ }),
  11675. /***/ "./2D/measure.ts":
  11676. /*!***********************!*\
  11677. !*** ./2D/measure.ts ***!
  11678. \***********************/
  11679. /*! exports provided: Measure */
  11680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11681. "use strict";
  11682. __webpack_require__.r(__webpack_exports__);
  11683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11684. /* harmony import */ var babylonjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs */ "babylonjs/Misc/observable");
  11685. /* harmony import */ var babylonjs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs__WEBPACK_IMPORTED_MODULE_0__);
  11686. /**
  11687. * Class used to store 2D control sizes
  11688. */
  11689. var Measure = /** @class */ (function () {
  11690. /**
  11691. * Creates a new measure
  11692. * @param left defines left coordinate
  11693. * @param top defines top coordinate
  11694. * @param width defines width dimension
  11695. * @param height defines height dimension
  11696. */
  11697. function Measure(
  11698. /** defines left coordinate */
  11699. left,
  11700. /** defines top coordinate */
  11701. top,
  11702. /** defines width dimension */
  11703. width,
  11704. /** defines height dimension */
  11705. height) {
  11706. this.left = left;
  11707. this.top = top;
  11708. this.width = width;
  11709. this.height = height;
  11710. }
  11711. /**
  11712. * Copy from another measure
  11713. * @param other defines the other measure to copy from
  11714. */
  11715. Measure.prototype.copyFrom = function (other) {
  11716. this.left = other.left;
  11717. this.top = other.top;
  11718. this.width = other.width;
  11719. this.height = other.height;
  11720. };
  11721. /**
  11722. * Copy from a group of 4 floats
  11723. * @param left defines left coordinate
  11724. * @param top defines top coordinate
  11725. * @param width defines width dimension
  11726. * @param height defines height dimension
  11727. */
  11728. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11729. this.left = left;
  11730. this.top = top;
  11731. this.width = width;
  11732. this.height = height;
  11733. };
  11734. /**
  11735. * Computes the axis aligned bounding box measure for two given measures
  11736. * @param a Input measure
  11737. * @param b Input measure
  11738. * @param result the resulting bounding measure
  11739. */
  11740. Measure.CombineToRef = function (a, b, result) {
  11741. var left = Math.min(a.left, b.left);
  11742. var top = Math.min(a.top, b.top);
  11743. var right = Math.max(a.left + a.width, b.left + b.width);
  11744. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11745. result.left = left;
  11746. result.top = top;
  11747. result.width = right - left;
  11748. result.height = bottom - top;
  11749. };
  11750. /**
  11751. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11752. * @param transform the matrix to transform the measure before computing the AABB
  11753. * @param result the resulting AABB
  11754. */
  11755. Measure.prototype.transformToRef = function (transform, result) {
  11756. var rectanglePoints = babylonjs__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11757. var min = new babylonjs__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11758. var max = new babylonjs__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11759. for (var i = 0; i < 4; i++) {
  11760. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11761. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11762. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11763. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11764. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11765. }
  11766. result.left = min.x;
  11767. result.top = min.y;
  11768. result.width = max.x - min.x;
  11769. result.height = max.y - min.y;
  11770. };
  11771. /**
  11772. * Check equality between this measure and another one
  11773. * @param other defines the other measures
  11774. * @returns true if both measures are equals
  11775. */
  11776. Measure.prototype.isEqualsTo = function (other) {
  11777. if (this.left !== other.left) {
  11778. return false;
  11779. }
  11780. if (this.top !== other.top) {
  11781. return false;
  11782. }
  11783. if (this.width !== other.width) {
  11784. return false;
  11785. }
  11786. if (this.height !== other.height) {
  11787. return false;
  11788. }
  11789. return true;
  11790. };
  11791. /**
  11792. * Creates an empty measure
  11793. * @returns a new measure
  11794. */
  11795. Measure.Empty = function () {
  11796. return new Measure(0, 0, 0, 0);
  11797. };
  11798. return Measure;
  11799. }());
  11800. /***/ }),
  11801. /***/ "./2D/multiLinePoint.ts":
  11802. /*!******************************!*\
  11803. !*** ./2D/multiLinePoint.ts ***!
  11804. \******************************/
  11805. /*! exports provided: MultiLinePoint */
  11806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11807. "use strict";
  11808. __webpack_require__.r(__webpack_exports__);
  11809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11810. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11811. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11812. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11813. /**
  11814. * Class used to store a point for a MultiLine object.
  11815. * The point can be pure 2D coordinates, a mesh or a control
  11816. */
  11817. var MultiLinePoint = /** @class */ (function () {
  11818. /**
  11819. * Creates a new MultiLinePoint
  11820. * @param multiLine defines the source MultiLine object
  11821. */
  11822. function MultiLinePoint(multiLine) {
  11823. this._multiLine = multiLine;
  11824. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11825. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11826. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11827. }
  11828. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11829. /** Gets or sets x coordinate */
  11830. get: function () {
  11831. return this._x.toString(this._multiLine._host);
  11832. },
  11833. set: function (value) {
  11834. if (this._x.toString(this._multiLine._host) === value) {
  11835. return;
  11836. }
  11837. if (this._x.fromString(value)) {
  11838. this._multiLine._markAsDirty();
  11839. }
  11840. },
  11841. enumerable: true,
  11842. configurable: true
  11843. });
  11844. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11845. /** Gets or sets y coordinate */
  11846. get: function () {
  11847. return this._y.toString(this._multiLine._host);
  11848. },
  11849. set: function (value) {
  11850. if (this._y.toString(this._multiLine._host) === value) {
  11851. return;
  11852. }
  11853. if (this._y.fromString(value)) {
  11854. this._multiLine._markAsDirty();
  11855. }
  11856. },
  11857. enumerable: true,
  11858. configurable: true
  11859. });
  11860. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11861. /** Gets or sets the control associated with this point */
  11862. get: function () {
  11863. return this._control;
  11864. },
  11865. set: function (value) {
  11866. if (this._control === value) {
  11867. return;
  11868. }
  11869. if (this._control && this._controlObserver) {
  11870. this._control.onDirtyObservable.remove(this._controlObserver);
  11871. this._controlObserver = null;
  11872. }
  11873. this._control = value;
  11874. if (this._control) {
  11875. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  11876. }
  11877. this._multiLine._markAsDirty();
  11878. },
  11879. enumerable: true,
  11880. configurable: true
  11881. });
  11882. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  11883. /** Gets or sets the mesh associated with this point */
  11884. get: function () {
  11885. return this._mesh;
  11886. },
  11887. set: function (value) {
  11888. if (this._mesh === value) {
  11889. return;
  11890. }
  11891. if (this._mesh && this._meshObserver) {
  11892. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  11893. }
  11894. this._mesh = value;
  11895. if (this._mesh) {
  11896. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  11897. }
  11898. this._multiLine._markAsDirty();
  11899. },
  11900. enumerable: true,
  11901. configurable: true
  11902. });
  11903. /** Resets links */
  11904. MultiLinePoint.prototype.resetLinks = function () {
  11905. this.control = null;
  11906. this.mesh = null;
  11907. };
  11908. /**
  11909. * Gets a translation vector
  11910. * @returns the translation vector
  11911. */
  11912. MultiLinePoint.prototype.translate = function () {
  11913. this._point = this._translatePoint();
  11914. return this._point;
  11915. };
  11916. MultiLinePoint.prototype._translatePoint = function () {
  11917. if (this._mesh != null) {
  11918. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  11919. }
  11920. else if (this._control != null) {
  11921. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  11922. }
  11923. else {
  11924. var host = this._multiLine._host;
  11925. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  11926. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  11927. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  11928. }
  11929. };
  11930. /** Release associated resources */
  11931. MultiLinePoint.prototype.dispose = function () {
  11932. this.resetLinks();
  11933. };
  11934. return MultiLinePoint;
  11935. }());
  11936. /***/ }),
  11937. /***/ "./2D/style.ts":
  11938. /*!*********************!*\
  11939. !*** ./2D/style.ts ***!
  11940. \*********************/
  11941. /*! exports provided: Style */
  11942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11943. "use strict";
  11944. __webpack_require__.r(__webpack_exports__);
  11945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  11946. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11947. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  11948. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11949. /**
  11950. * Define a style used by control to automatically setup properties based on a template.
  11951. * Only support font related properties so far
  11952. */
  11953. var Style = /** @class */ (function () {
  11954. /**
  11955. * Creates a new style object
  11956. * @param host defines the AdvancedDynamicTexture which hosts this style
  11957. */
  11958. function Style(host) {
  11959. this._fontFamily = "Arial";
  11960. this._fontStyle = "";
  11961. this._fontWeight = "";
  11962. /** @hidden */
  11963. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  11964. /**
  11965. * Observable raised when the style values are changed
  11966. */
  11967. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  11968. this._host = host;
  11969. }
  11970. Object.defineProperty(Style.prototype, "fontSize", {
  11971. /**
  11972. * Gets or sets the font size
  11973. */
  11974. get: function () {
  11975. return this._fontSize.toString(this._host);
  11976. },
  11977. set: function (value) {
  11978. if (this._fontSize.toString(this._host) === value) {
  11979. return;
  11980. }
  11981. if (this._fontSize.fromString(value)) {
  11982. this.onChangedObservable.notifyObservers(this);
  11983. }
  11984. },
  11985. enumerable: true,
  11986. configurable: true
  11987. });
  11988. Object.defineProperty(Style.prototype, "fontFamily", {
  11989. /**
  11990. * Gets or sets the font family
  11991. */
  11992. get: function () {
  11993. return this._fontFamily;
  11994. },
  11995. set: function (value) {
  11996. if (this._fontFamily === value) {
  11997. return;
  11998. }
  11999. this._fontFamily = value;
  12000. this.onChangedObservable.notifyObservers(this);
  12001. },
  12002. enumerable: true,
  12003. configurable: true
  12004. });
  12005. Object.defineProperty(Style.prototype, "fontStyle", {
  12006. /**
  12007. * Gets or sets the font style
  12008. */
  12009. get: function () {
  12010. return this._fontStyle;
  12011. },
  12012. set: function (value) {
  12013. if (this._fontStyle === value) {
  12014. return;
  12015. }
  12016. this._fontStyle = value;
  12017. this.onChangedObservable.notifyObservers(this);
  12018. },
  12019. enumerable: true,
  12020. configurable: true
  12021. });
  12022. Object.defineProperty(Style.prototype, "fontWeight", {
  12023. /** Gets or sets font weight */
  12024. get: function () {
  12025. return this._fontWeight;
  12026. },
  12027. set: function (value) {
  12028. if (this._fontWeight === value) {
  12029. return;
  12030. }
  12031. this._fontWeight = value;
  12032. this.onChangedObservable.notifyObservers(this);
  12033. },
  12034. enumerable: true,
  12035. configurable: true
  12036. });
  12037. /** Dispose all associated resources */
  12038. Style.prototype.dispose = function () {
  12039. this.onChangedObservable.clear();
  12040. };
  12041. return Style;
  12042. }());
  12043. /***/ }),
  12044. /***/ "./2D/valueAndUnit.ts":
  12045. /*!****************************!*\
  12046. !*** ./2D/valueAndUnit.ts ***!
  12047. \****************************/
  12048. /*! exports provided: ValueAndUnit */
  12049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12050. "use strict";
  12051. __webpack_require__.r(__webpack_exports__);
  12052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12053. /**
  12054. * Class used to specific a value and its associated unit
  12055. */
  12056. var ValueAndUnit = /** @class */ (function () {
  12057. /**
  12058. * Creates a new ValueAndUnit
  12059. * @param value defines the value to store
  12060. * @param unit defines the unit to store
  12061. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12062. */
  12063. function ValueAndUnit(value,
  12064. /** defines the unit to store */
  12065. unit,
  12066. /** defines a boolean indicating if the value can be negative */
  12067. negativeValueAllowed) {
  12068. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12069. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12070. this.unit = unit;
  12071. this.negativeValueAllowed = negativeValueAllowed;
  12072. this._value = 1;
  12073. /**
  12074. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12075. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12076. */
  12077. this.ignoreAdaptiveScaling = false;
  12078. this._value = value;
  12079. this._originalUnit = unit;
  12080. }
  12081. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12082. /** Gets a boolean indicating if the value is a percentage */
  12083. get: function () {
  12084. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12085. },
  12086. enumerable: true,
  12087. configurable: true
  12088. });
  12089. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12090. /** Gets a boolean indicating if the value is store as pixel */
  12091. get: function () {
  12092. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12093. },
  12094. enumerable: true,
  12095. configurable: true
  12096. });
  12097. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12098. /** Gets direct internal value */
  12099. get: function () {
  12100. return this._value;
  12101. },
  12102. enumerable: true,
  12103. configurable: true
  12104. });
  12105. /**
  12106. * Gets value as pixel
  12107. * @param host defines the root host
  12108. * @param refValue defines the reference value for percentages
  12109. * @returns the value as pixel
  12110. */
  12111. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12112. if (this.isPixel) {
  12113. return this.getValue(host);
  12114. }
  12115. return this.getValue(host) * refValue;
  12116. };
  12117. /**
  12118. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12119. * @param value defines the value to store
  12120. * @param unit defines the unit to store
  12121. * @returns the current ValueAndUnit
  12122. */
  12123. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12124. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12125. this._value = value;
  12126. this.unit = unit;
  12127. return this;
  12128. };
  12129. /**
  12130. * Gets the value accordingly to its unit
  12131. * @param host defines the root host
  12132. * @returns the value
  12133. */
  12134. ValueAndUnit.prototype.getValue = function (host) {
  12135. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12136. var width = 0;
  12137. var height = 0;
  12138. if (host.idealWidth) {
  12139. width = (this._value * host.getSize().width) / host.idealWidth;
  12140. }
  12141. if (host.idealHeight) {
  12142. height = (this._value * host.getSize().height) / host.idealHeight;
  12143. }
  12144. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12145. return window.innerWidth < window.innerHeight ? width : height;
  12146. }
  12147. if (host.idealWidth) { // horizontal
  12148. return width;
  12149. }
  12150. if (host.idealHeight) { // vertical
  12151. return height;
  12152. }
  12153. }
  12154. return this._value;
  12155. };
  12156. /**
  12157. * Gets a string representation of the value
  12158. * @param host defines the root host
  12159. * @returns a string
  12160. */
  12161. ValueAndUnit.prototype.toString = function (host) {
  12162. switch (this.unit) {
  12163. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12164. return (this.getValue(host) * 100) + "%";
  12165. case ValueAndUnit.UNITMODE_PIXEL:
  12166. return this.getValue(host) + "px";
  12167. }
  12168. return this.unit.toString();
  12169. };
  12170. /**
  12171. * Store a value parsed from a string
  12172. * @param source defines the source string
  12173. * @returns true if the value was successfully parsed
  12174. */
  12175. ValueAndUnit.prototype.fromString = function (source) {
  12176. var match = ValueAndUnit._Regex.exec(source.toString());
  12177. if (!match || match.length === 0) {
  12178. return false;
  12179. }
  12180. var sourceValue = parseFloat(match[1]);
  12181. var sourceUnit = this._originalUnit;
  12182. if (!this.negativeValueAllowed) {
  12183. if (sourceValue < 0) {
  12184. sourceValue = 0;
  12185. }
  12186. }
  12187. if (match.length === 4) {
  12188. switch (match[3]) {
  12189. case "px":
  12190. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12191. break;
  12192. case "%":
  12193. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12194. sourceValue /= 100.0;
  12195. break;
  12196. }
  12197. }
  12198. if (sourceValue === this._value && sourceUnit === this.unit) {
  12199. return false;
  12200. }
  12201. this._value = sourceValue;
  12202. this.unit = sourceUnit;
  12203. return true;
  12204. };
  12205. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12206. /** UNITMODE_PERCENTAGE */
  12207. get: function () {
  12208. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12209. },
  12210. enumerable: true,
  12211. configurable: true
  12212. });
  12213. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12214. /** UNITMODE_PIXEL */
  12215. get: function () {
  12216. return ValueAndUnit._UNITMODE_PIXEL;
  12217. },
  12218. enumerable: true,
  12219. configurable: true
  12220. });
  12221. // Static
  12222. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12223. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12224. ValueAndUnit._UNITMODE_PIXEL = 1;
  12225. return ValueAndUnit;
  12226. }());
  12227. /***/ }),
  12228. /***/ "./3D/controls/abstractButton3D.ts":
  12229. /*!*****************************************!*\
  12230. !*** ./3D/controls/abstractButton3D.ts ***!
  12231. \*****************************************/
  12232. /*! exports provided: AbstractButton3D */
  12233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12234. "use strict";
  12235. __webpack_require__.r(__webpack_exports__);
  12236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12237. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12238. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12239. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12240. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12241. /**
  12242. * Class used as a root to all buttons
  12243. */
  12244. var AbstractButton3D = /** @class */ (function (_super) {
  12245. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12246. /**
  12247. * Creates a new button
  12248. * @param name defines the control name
  12249. */
  12250. function AbstractButton3D(name) {
  12251. return _super.call(this, name) || this;
  12252. }
  12253. AbstractButton3D.prototype._getTypeName = function () {
  12254. return "AbstractButton3D";
  12255. };
  12256. // Mesh association
  12257. AbstractButton3D.prototype._createNode = function (scene) {
  12258. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12259. };
  12260. return AbstractButton3D;
  12261. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12262. /***/ }),
  12263. /***/ "./3D/controls/button3D.ts":
  12264. /*!*********************************!*\
  12265. !*** ./3D/controls/button3D.ts ***!
  12266. \*********************************/
  12267. /*! exports provided: Button3D */
  12268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12269. "use strict";
  12270. __webpack_require__.r(__webpack_exports__);
  12271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12272. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12273. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  12274. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12275. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12276. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12277. /**
  12278. * Class used to create a button in 3D
  12279. */
  12280. var Button3D = /** @class */ (function (_super) {
  12281. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12282. /**
  12283. * Creates a new button
  12284. * @param name defines the control name
  12285. */
  12286. function Button3D(name) {
  12287. var _this = _super.call(this, name) || this;
  12288. _this._contentResolution = 512;
  12289. _this._contentScaleRatio = 2;
  12290. // Default animations
  12291. _this.pointerEnterAnimation = function () {
  12292. if (!_this.mesh) {
  12293. return;
  12294. }
  12295. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12296. };
  12297. _this.pointerOutAnimation = function () {
  12298. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12299. };
  12300. _this.pointerDownAnimation = function () {
  12301. if (!_this.mesh) {
  12302. return;
  12303. }
  12304. _this.mesh.scaling.scaleInPlace(0.95);
  12305. };
  12306. _this.pointerUpAnimation = function () {
  12307. if (!_this.mesh) {
  12308. return;
  12309. }
  12310. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12311. };
  12312. return _this;
  12313. }
  12314. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12315. /**
  12316. * Gets or sets the texture resolution used to render content (512 by default)
  12317. */
  12318. get: function () {
  12319. return this._contentResolution;
  12320. },
  12321. set: function (value) {
  12322. if (this._contentResolution === value) {
  12323. return;
  12324. }
  12325. this._contentResolution = value;
  12326. this._resetContent();
  12327. },
  12328. enumerable: true,
  12329. configurable: true
  12330. });
  12331. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12332. /**
  12333. * Gets or sets the texture scale ratio used to render content (2 by default)
  12334. */
  12335. get: function () {
  12336. return this._contentScaleRatio;
  12337. },
  12338. set: function (value) {
  12339. if (this._contentScaleRatio === value) {
  12340. return;
  12341. }
  12342. this._contentScaleRatio = value;
  12343. this._resetContent();
  12344. },
  12345. enumerable: true,
  12346. configurable: true
  12347. });
  12348. Button3D.prototype._disposeFacadeTexture = function () {
  12349. if (this._facadeTexture) {
  12350. this._facadeTexture.dispose();
  12351. this._facadeTexture = null;
  12352. }
  12353. };
  12354. Button3D.prototype._resetContent = function () {
  12355. this._disposeFacadeTexture();
  12356. this.content = this._content;
  12357. };
  12358. Object.defineProperty(Button3D.prototype, "content", {
  12359. /**
  12360. * Gets or sets the GUI 2D content used to display the button's facade
  12361. */
  12362. get: function () {
  12363. return this._content;
  12364. },
  12365. set: function (value) {
  12366. this._content = value;
  12367. if (!this._host || !this._host.utilityLayer) {
  12368. return;
  12369. }
  12370. if (!this._facadeTexture) {
  12371. this._facadeTexture = new _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__["AdvancedDynamicTexture"]("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  12372. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12373. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12374. this._facadeTexture.premulAlpha = true;
  12375. }
  12376. this._facadeTexture.addControl(value);
  12377. this._applyFacade(this._facadeTexture);
  12378. },
  12379. enumerable: true,
  12380. configurable: true
  12381. });
  12382. /**
  12383. * Apply the facade texture (created from the content property).
  12384. * This function can be overloaded by child classes
  12385. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12386. */
  12387. Button3D.prototype._applyFacade = function (facadeTexture) {
  12388. this._currentMaterial.emissiveTexture = facadeTexture;
  12389. };
  12390. Button3D.prototype._getTypeName = function () {
  12391. return "Button3D";
  12392. };
  12393. // Mesh association
  12394. Button3D.prototype._createNode = function (scene) {
  12395. var faceUV = new Array(6);
  12396. for (var i = 0; i < 6; i++) {
  12397. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12398. }
  12399. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12400. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12401. width: 1.0,
  12402. height: 1.0,
  12403. depth: 0.08,
  12404. faceUV: faceUV
  12405. }, scene);
  12406. return mesh;
  12407. };
  12408. Button3D.prototype._affectMaterial = function (mesh) {
  12409. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12410. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12411. mesh.material = material;
  12412. this._currentMaterial = material;
  12413. this._resetContent();
  12414. };
  12415. /**
  12416. * Releases all associated resources
  12417. */
  12418. Button3D.prototype.dispose = function () {
  12419. _super.prototype.dispose.call(this);
  12420. this._disposeFacadeTexture();
  12421. if (this._currentMaterial) {
  12422. this._currentMaterial.dispose();
  12423. }
  12424. };
  12425. return Button3D;
  12426. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12427. /***/ }),
  12428. /***/ "./3D/controls/container3D.ts":
  12429. /*!************************************!*\
  12430. !*** ./3D/controls/container3D.ts ***!
  12431. \************************************/
  12432. /*! exports provided: Container3D */
  12433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12434. "use strict";
  12435. __webpack_require__.r(__webpack_exports__);
  12436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12437. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12438. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12439. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12440. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12441. /**
  12442. * Class used to create containers for controls
  12443. */
  12444. var Container3D = /** @class */ (function (_super) {
  12445. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12446. /**
  12447. * Creates a new container
  12448. * @param name defines the container name
  12449. */
  12450. function Container3D(name) {
  12451. var _this = _super.call(this, name) || this;
  12452. _this._blockLayout = false;
  12453. /**
  12454. * Gets the list of child controls
  12455. */
  12456. _this._children = new Array();
  12457. return _this;
  12458. }
  12459. Object.defineProperty(Container3D.prototype, "children", {
  12460. /**
  12461. * Gets the list of child controls
  12462. */
  12463. get: function () {
  12464. return this._children;
  12465. },
  12466. enumerable: true,
  12467. configurable: true
  12468. });
  12469. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12470. /**
  12471. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12472. * This is helpful to optimize layout operation when adding multiple children in a row
  12473. */
  12474. get: function () {
  12475. return this._blockLayout;
  12476. },
  12477. set: function (value) {
  12478. if (this._blockLayout === value) {
  12479. return;
  12480. }
  12481. this._blockLayout = value;
  12482. if (!this._blockLayout) {
  12483. this._arrangeChildren();
  12484. }
  12485. },
  12486. enumerable: true,
  12487. configurable: true
  12488. });
  12489. /**
  12490. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12491. * @returns the current container
  12492. */
  12493. Container3D.prototype.updateLayout = function () {
  12494. this._arrangeChildren();
  12495. return this;
  12496. };
  12497. /**
  12498. * Gets a boolean indicating if the given control is in the children of this control
  12499. * @param control defines the control to check
  12500. * @returns true if the control is in the child list
  12501. */
  12502. Container3D.prototype.containsControl = function (control) {
  12503. return this._children.indexOf(control) !== -1;
  12504. };
  12505. /**
  12506. * Adds a control to the children of this control
  12507. * @param control defines the control to add
  12508. * @returns the current container
  12509. */
  12510. Container3D.prototype.addControl = function (control) {
  12511. var index = this._children.indexOf(control);
  12512. if (index !== -1) {
  12513. return this;
  12514. }
  12515. control.parent = this;
  12516. control._host = this._host;
  12517. this._children.push(control);
  12518. if (this._host.utilityLayer) {
  12519. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12520. if (control.node) {
  12521. control.node.parent = this.node;
  12522. }
  12523. if (!this.blockLayout) {
  12524. this._arrangeChildren();
  12525. }
  12526. }
  12527. return this;
  12528. };
  12529. /**
  12530. * This function will be called everytime a new control is added
  12531. */
  12532. Container3D.prototype._arrangeChildren = function () {
  12533. };
  12534. Container3D.prototype._createNode = function (scene) {
  12535. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12536. };
  12537. /**
  12538. * Removes a control from the children of this control
  12539. * @param control defines the control to remove
  12540. * @returns the current container
  12541. */
  12542. Container3D.prototype.removeControl = function (control) {
  12543. var index = this._children.indexOf(control);
  12544. if (index !== -1) {
  12545. this._children.splice(index, 1);
  12546. control.parent = null;
  12547. control._disposeNode();
  12548. }
  12549. return this;
  12550. };
  12551. Container3D.prototype._getTypeName = function () {
  12552. return "Container3D";
  12553. };
  12554. /**
  12555. * Releases all associated resources
  12556. */
  12557. Container3D.prototype.dispose = function () {
  12558. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12559. var control = _a[_i];
  12560. control.dispose();
  12561. }
  12562. this._children = [];
  12563. _super.prototype.dispose.call(this);
  12564. };
  12565. /** Control rotation will remain unchanged */
  12566. Container3D.UNSET_ORIENTATION = 0;
  12567. /** Control will rotate to make it look at sphere central axis */
  12568. Container3D.FACEORIGIN_ORIENTATION = 1;
  12569. /** Control will rotate to make it look back at sphere central axis */
  12570. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12571. /** Control will rotate to look at z axis (0, 0, 1) */
  12572. Container3D.FACEFORWARD_ORIENTATION = 3;
  12573. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12574. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12575. return Container3D;
  12576. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12577. /***/ }),
  12578. /***/ "./3D/controls/control3D.ts":
  12579. /*!**********************************!*\
  12580. !*** ./3D/controls/control3D.ts ***!
  12581. \**********************************/
  12582. /*! exports provided: Control3D */
  12583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12584. "use strict";
  12585. __webpack_require__.r(__webpack_exports__);
  12586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12587. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12588. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12589. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12590. /**
  12591. * Class used as base class for controls
  12592. */
  12593. var Control3D = /** @class */ (function () {
  12594. /**
  12595. * Creates a new control
  12596. * @param name defines the control name
  12597. */
  12598. function Control3D(
  12599. /** Defines the control name */
  12600. name) {
  12601. this.name = name;
  12602. this._downCount = 0;
  12603. this._enterCount = -1;
  12604. this._downPointerIds = {};
  12605. this._isVisible = true;
  12606. /**
  12607. * An event triggered when the pointer move over the control
  12608. */
  12609. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12610. /**
  12611. * An event triggered when the pointer move out of the control
  12612. */
  12613. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12614. /**
  12615. * An event triggered when the pointer taps the control
  12616. */
  12617. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12618. /**
  12619. * An event triggered when pointer is up
  12620. */
  12621. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12622. /**
  12623. * An event triggered when a control is clicked on (with a mouse)
  12624. */
  12625. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12626. /**
  12627. * An event triggered when pointer enters the control
  12628. */
  12629. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12630. // Behaviors
  12631. this._behaviors = new Array();
  12632. }
  12633. Object.defineProperty(Control3D.prototype, "position", {
  12634. /** Gets or sets the control position in world space */
  12635. get: function () {
  12636. if (!this._node) {
  12637. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12638. }
  12639. return this._node.position;
  12640. },
  12641. set: function (value) {
  12642. if (!this._node) {
  12643. return;
  12644. }
  12645. this._node.position = value;
  12646. },
  12647. enumerable: true,
  12648. configurable: true
  12649. });
  12650. Object.defineProperty(Control3D.prototype, "scaling", {
  12651. /** Gets or sets the control scaling in world space */
  12652. get: function () {
  12653. if (!this._node) {
  12654. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12655. }
  12656. return this._node.scaling;
  12657. },
  12658. set: function (value) {
  12659. if (!this._node) {
  12660. return;
  12661. }
  12662. this._node.scaling = value;
  12663. },
  12664. enumerable: true,
  12665. configurable: true
  12666. });
  12667. Object.defineProperty(Control3D.prototype, "behaviors", {
  12668. /**
  12669. * Gets the list of attached behaviors
  12670. * @see http://doc.babylonjs.com/features/behaviour
  12671. */
  12672. get: function () {
  12673. return this._behaviors;
  12674. },
  12675. enumerable: true,
  12676. configurable: true
  12677. });
  12678. /**
  12679. * Attach a behavior to the control
  12680. * @see http://doc.babylonjs.com/features/behaviour
  12681. * @param behavior defines the behavior to attach
  12682. * @returns the current control
  12683. */
  12684. Control3D.prototype.addBehavior = function (behavior) {
  12685. var _this = this;
  12686. var index = this._behaviors.indexOf(behavior);
  12687. if (index !== -1) {
  12688. return this;
  12689. }
  12690. behavior.init();
  12691. var scene = this._host.scene;
  12692. if (scene.isLoading) {
  12693. // We defer the attach when the scene will be loaded
  12694. scene.onDataLoadedObservable.addOnce(function () {
  12695. behavior.attach(_this);
  12696. });
  12697. }
  12698. else {
  12699. behavior.attach(this);
  12700. }
  12701. this._behaviors.push(behavior);
  12702. return this;
  12703. };
  12704. /**
  12705. * Remove an attached behavior
  12706. * @see http://doc.babylonjs.com/features/behaviour
  12707. * @param behavior defines the behavior to attach
  12708. * @returns the current control
  12709. */
  12710. Control3D.prototype.removeBehavior = function (behavior) {
  12711. var index = this._behaviors.indexOf(behavior);
  12712. if (index === -1) {
  12713. return this;
  12714. }
  12715. this._behaviors[index].detach();
  12716. this._behaviors.splice(index, 1);
  12717. return this;
  12718. };
  12719. /**
  12720. * Gets an attached behavior by name
  12721. * @param name defines the name of the behavior to look for
  12722. * @see http://doc.babylonjs.com/features/behaviour
  12723. * @returns null if behavior was not found else the requested behavior
  12724. */
  12725. Control3D.prototype.getBehaviorByName = function (name) {
  12726. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12727. var behavior = _a[_i];
  12728. if (behavior.name === name) {
  12729. return behavior;
  12730. }
  12731. }
  12732. return null;
  12733. };
  12734. Object.defineProperty(Control3D.prototype, "isVisible", {
  12735. /** Gets or sets a boolean indicating if the control is visible */
  12736. get: function () {
  12737. return this._isVisible;
  12738. },
  12739. set: function (value) {
  12740. if (this._isVisible === value) {
  12741. return;
  12742. }
  12743. this._isVisible = value;
  12744. var mesh = this.mesh;
  12745. if (mesh) {
  12746. mesh.setEnabled(value);
  12747. }
  12748. },
  12749. enumerable: true,
  12750. configurable: true
  12751. });
  12752. Object.defineProperty(Control3D.prototype, "typeName", {
  12753. /**
  12754. * Gets a string representing the class name
  12755. */
  12756. get: function () {
  12757. return this._getTypeName();
  12758. },
  12759. enumerable: true,
  12760. configurable: true
  12761. });
  12762. /**
  12763. * Get the current class name of the control.
  12764. * @returns current class name
  12765. */
  12766. Control3D.prototype.getClassName = function () {
  12767. return this._getTypeName();
  12768. };
  12769. Control3D.prototype._getTypeName = function () {
  12770. return "Control3D";
  12771. };
  12772. Object.defineProperty(Control3D.prototype, "node", {
  12773. /**
  12774. * Gets the transform node used by this control
  12775. */
  12776. get: function () {
  12777. return this._node;
  12778. },
  12779. enumerable: true,
  12780. configurable: true
  12781. });
  12782. Object.defineProperty(Control3D.prototype, "mesh", {
  12783. /**
  12784. * Gets the mesh used to render this control
  12785. */
  12786. get: function () {
  12787. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12788. return this._node;
  12789. }
  12790. return null;
  12791. },
  12792. enumerable: true,
  12793. configurable: true
  12794. });
  12795. /**
  12796. * Link the control as child of the given node
  12797. * @param node defines the node to link to. Use null to unlink the control
  12798. * @returns the current control
  12799. */
  12800. Control3D.prototype.linkToTransformNode = function (node) {
  12801. if (this._node) {
  12802. this._node.parent = node;
  12803. }
  12804. return this;
  12805. };
  12806. /** @hidden **/
  12807. Control3D.prototype._prepareNode = function (scene) {
  12808. if (!this._node) {
  12809. this._node = this._createNode(scene);
  12810. if (!this.node) {
  12811. return;
  12812. }
  12813. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12814. this._node.position = this.position;
  12815. this._node.scaling = this.scaling;
  12816. var mesh = this.mesh;
  12817. if (mesh) {
  12818. mesh.isPickable = true;
  12819. this._affectMaterial(mesh);
  12820. }
  12821. }
  12822. };
  12823. /**
  12824. * Node creation.
  12825. * Can be overriden by children
  12826. * @param scene defines the scene where the node must be attached
  12827. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12828. */
  12829. Control3D.prototype._createNode = function (scene) {
  12830. // Do nothing by default
  12831. return null;
  12832. };
  12833. /**
  12834. * Affect a material to the given mesh
  12835. * @param mesh defines the mesh which will represent the control
  12836. */
  12837. Control3D.prototype._affectMaterial = function (mesh) {
  12838. mesh.material = null;
  12839. };
  12840. // Pointers
  12841. /** @hidden */
  12842. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12843. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12844. };
  12845. /** @hidden */
  12846. Control3D.prototype._onPointerEnter = function (target) {
  12847. if (this._enterCount > 0) {
  12848. return false;
  12849. }
  12850. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12851. this._enterCount = 0;
  12852. }
  12853. this._enterCount++;
  12854. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12855. if (this.pointerEnterAnimation) {
  12856. this.pointerEnterAnimation();
  12857. }
  12858. return true;
  12859. };
  12860. /** @hidden */
  12861. Control3D.prototype._onPointerOut = function (target) {
  12862. this._enterCount = 0;
  12863. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  12864. if (this.pointerOutAnimation) {
  12865. this.pointerOutAnimation();
  12866. }
  12867. };
  12868. /** @hidden */
  12869. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  12870. if (this._downCount !== 0) {
  12871. return false;
  12872. }
  12873. this._downCount++;
  12874. this._downPointerIds[pointerId] = true;
  12875. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12876. if (this.pointerDownAnimation) {
  12877. this.pointerDownAnimation();
  12878. }
  12879. return true;
  12880. };
  12881. /** @hidden */
  12882. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  12883. this._downCount = 0;
  12884. delete this._downPointerIds[pointerId];
  12885. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  12886. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12887. }
  12888. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12889. if (this.pointerUpAnimation) {
  12890. this.pointerUpAnimation();
  12891. }
  12892. };
  12893. /** @hidden */
  12894. Control3D.prototype.forcePointerUp = function (pointerId) {
  12895. if (pointerId === void 0) { pointerId = null; }
  12896. if (pointerId !== null) {
  12897. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  12898. }
  12899. else {
  12900. for (var key in this._downPointerIds) {
  12901. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  12902. }
  12903. }
  12904. };
  12905. /** @hidden */
  12906. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  12907. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  12908. this._onPointerMove(this, pickedPoint);
  12909. var previousControlOver = this._host._lastControlOver[pointerId];
  12910. if (previousControlOver && previousControlOver !== this) {
  12911. previousControlOver._onPointerOut(this);
  12912. }
  12913. if (previousControlOver !== this) {
  12914. this._onPointerEnter(this);
  12915. }
  12916. this._host._lastControlOver[pointerId] = this;
  12917. return true;
  12918. }
  12919. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  12920. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  12921. this._host._lastControlDown[pointerId] = this;
  12922. this._host._lastPickedControl = this;
  12923. return true;
  12924. }
  12925. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  12926. if (this._host._lastControlDown[pointerId]) {
  12927. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  12928. }
  12929. delete this._host._lastControlDown[pointerId];
  12930. return true;
  12931. }
  12932. return false;
  12933. };
  12934. /** @hidden */
  12935. Control3D.prototype._disposeNode = function () {
  12936. if (this._node) {
  12937. this._node.dispose();
  12938. this._node = null;
  12939. }
  12940. };
  12941. /**
  12942. * Releases all associated resources
  12943. */
  12944. Control3D.prototype.dispose = function () {
  12945. this.onPointerDownObservable.clear();
  12946. this.onPointerEnterObservable.clear();
  12947. this.onPointerMoveObservable.clear();
  12948. this.onPointerOutObservable.clear();
  12949. this.onPointerUpObservable.clear();
  12950. this.onPointerClickObservable.clear();
  12951. this._disposeNode();
  12952. // Behaviors
  12953. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12954. var behavior = _a[_i];
  12955. behavior.detach();
  12956. }
  12957. };
  12958. return Control3D;
  12959. }());
  12960. /***/ }),
  12961. /***/ "./3D/controls/cylinderPanel.ts":
  12962. /*!**************************************!*\
  12963. !*** ./3D/controls/cylinderPanel.ts ***!
  12964. \**************************************/
  12965. /*! exports provided: CylinderPanel */
  12966. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12967. "use strict";
  12968. __webpack_require__.r(__webpack_exports__);
  12969. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  12970. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12971. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  12972. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  12973. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  12974. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  12975. /**
  12976. * Class used to create a container panel deployed on the surface of a cylinder
  12977. */
  12978. var CylinderPanel = /** @class */ (function (_super) {
  12979. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  12980. function CylinderPanel() {
  12981. var _this = _super !== null && _super.apply(this, arguments) || this;
  12982. _this._radius = 5.0;
  12983. return _this;
  12984. }
  12985. Object.defineProperty(CylinderPanel.prototype, "radius", {
  12986. /**
  12987. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  12988. */
  12989. get: function () {
  12990. return this._radius;
  12991. },
  12992. set: function (value) {
  12993. var _this = this;
  12994. if (this._radius === value) {
  12995. return;
  12996. }
  12997. this._radius = value;
  12998. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  12999. _this._arrangeChildren();
  13000. });
  13001. },
  13002. enumerable: true,
  13003. configurable: true
  13004. });
  13005. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13006. var mesh = control.mesh;
  13007. if (!mesh) {
  13008. return;
  13009. }
  13010. var newPos = this._cylindricalMapping(nodePosition);
  13011. control.position = newPos;
  13012. switch (this.orientation) {
  13013. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13014. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13015. break;
  13016. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13017. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13018. break;
  13019. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13020. break;
  13021. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13022. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13023. break;
  13024. }
  13025. };
  13026. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13027. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13028. var yAngle = (source.x / this._radius);
  13029. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13030. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13031. };
  13032. return CylinderPanel;
  13033. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13034. /***/ }),
  13035. /***/ "./3D/controls/holographicButton.ts":
  13036. /*!******************************************!*\
  13037. !*** ./3D/controls/holographicButton.ts ***!
  13038. \******************************************/
  13039. /*! exports provided: HolographicButton */
  13040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13041. "use strict";
  13042. __webpack_require__.r(__webpack_exports__);
  13043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13044. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13045. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13046. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13047. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13048. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13049. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13050. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13051. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13052. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13053. /**
  13054. * Class used to create a holographic button in 3D
  13055. */
  13056. var HolographicButton = /** @class */ (function (_super) {
  13057. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13058. /**
  13059. * Creates a new button
  13060. * @param name defines the control name
  13061. */
  13062. function HolographicButton(name, shareMaterials) {
  13063. if (shareMaterials === void 0) { shareMaterials = true; }
  13064. var _this = _super.call(this, name) || this;
  13065. _this._shareMaterials = true;
  13066. _this._shareMaterials = shareMaterials;
  13067. // Default animations
  13068. _this.pointerEnterAnimation = function () {
  13069. if (!_this.mesh) {
  13070. return;
  13071. }
  13072. _this._frontPlate.setEnabled(true);
  13073. };
  13074. _this.pointerOutAnimation = function () {
  13075. if (!_this.mesh) {
  13076. return;
  13077. }
  13078. _this._frontPlate.setEnabled(false);
  13079. };
  13080. return _this;
  13081. }
  13082. HolographicButton.prototype._disposeTooltip = function () {
  13083. this._tooltipFade = null;
  13084. if (this._tooltipTextBlock) {
  13085. this._tooltipTextBlock.dispose();
  13086. }
  13087. if (this._tooltipTexture) {
  13088. this._tooltipTexture.dispose();
  13089. }
  13090. if (this._tooltipMesh) {
  13091. this._tooltipMesh.dispose();
  13092. }
  13093. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13094. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13095. };
  13096. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13097. get: function () {
  13098. if (this._tooltipTextBlock) {
  13099. return this._tooltipTextBlock.text;
  13100. }
  13101. return null;
  13102. },
  13103. /**
  13104. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13105. */
  13106. set: function (text) {
  13107. var _this = this;
  13108. if (!text) {
  13109. this._disposeTooltip();
  13110. return;
  13111. }
  13112. if (!this._tooltipFade) {
  13113. // Create tooltip with mesh and text
  13114. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13115. 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);
  13116. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13117. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13118. tooltipBackground.material = mat;
  13119. tooltipBackground.isPickable = false;
  13120. this._tooltipMesh.addChild(tooltipBackground);
  13121. tooltipBackground.position.z = 0.05;
  13122. this._tooltipMesh.scaling.y = 1 / 3;
  13123. this._tooltipMesh.position.y = 0.7;
  13124. this._tooltipMesh.position.z = -0.15;
  13125. this._tooltipMesh.isPickable = false;
  13126. this._tooltipMesh.parent = this._backPlate;
  13127. // Create text texture for the tooltip
  13128. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13129. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13130. this._tooltipTextBlock.scaleY = 3;
  13131. this._tooltipTextBlock.color = "white";
  13132. this._tooltipTextBlock.fontSize = 130;
  13133. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13134. // Add hover action to tooltip
  13135. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13136. this._tooltipFade.delay = 500;
  13137. this._tooltipMesh.addBehavior(this._tooltipFade);
  13138. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13139. if (_this._tooltipFade) {
  13140. _this._tooltipFade.fadeIn(true);
  13141. }
  13142. });
  13143. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13144. if (_this._tooltipFade) {
  13145. _this._tooltipFade.fadeIn(false);
  13146. }
  13147. });
  13148. }
  13149. if (this._tooltipTextBlock) {
  13150. this._tooltipTextBlock.text = text;
  13151. }
  13152. },
  13153. enumerable: true,
  13154. configurable: true
  13155. });
  13156. Object.defineProperty(HolographicButton.prototype, "text", {
  13157. /**
  13158. * Gets or sets text for the button
  13159. */
  13160. get: function () {
  13161. return this._text;
  13162. },
  13163. set: function (value) {
  13164. if (this._text === value) {
  13165. return;
  13166. }
  13167. this._text = value;
  13168. this._rebuildContent();
  13169. },
  13170. enumerable: true,
  13171. configurable: true
  13172. });
  13173. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13174. /**
  13175. * Gets or sets the image url for the button
  13176. */
  13177. get: function () {
  13178. return this._imageUrl;
  13179. },
  13180. set: function (value) {
  13181. if (this._imageUrl === value) {
  13182. return;
  13183. }
  13184. this._imageUrl = value;
  13185. this._rebuildContent();
  13186. },
  13187. enumerable: true,
  13188. configurable: true
  13189. });
  13190. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13191. /**
  13192. * Gets the back material used by this button
  13193. */
  13194. get: function () {
  13195. return this._backMaterial;
  13196. },
  13197. enumerable: true,
  13198. configurable: true
  13199. });
  13200. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13201. /**
  13202. * Gets the front material used by this button
  13203. */
  13204. get: function () {
  13205. return this._frontMaterial;
  13206. },
  13207. enumerable: true,
  13208. configurable: true
  13209. });
  13210. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13211. /**
  13212. * Gets the plate material used by this button
  13213. */
  13214. get: function () {
  13215. return this._plateMaterial;
  13216. },
  13217. enumerable: true,
  13218. configurable: true
  13219. });
  13220. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13221. /**
  13222. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13223. */
  13224. get: function () {
  13225. return this._shareMaterials;
  13226. },
  13227. enumerable: true,
  13228. configurable: true
  13229. });
  13230. HolographicButton.prototype._getTypeName = function () {
  13231. return "HolographicButton";
  13232. };
  13233. HolographicButton.prototype._rebuildContent = function () {
  13234. this._disposeFacadeTexture();
  13235. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13236. panel.isVertical = true;
  13237. if (this._imageUrl) {
  13238. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13239. image.source = this._imageUrl;
  13240. image.paddingTop = "40px";
  13241. image.height = "180px";
  13242. image.width = "100px";
  13243. image.paddingBottom = "40px";
  13244. panel.addControl(image);
  13245. }
  13246. if (this._text) {
  13247. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13248. text.text = this._text;
  13249. text.color = "white";
  13250. text.height = "30px";
  13251. text.fontSize = 24;
  13252. panel.addControl(text);
  13253. }
  13254. if (this._frontPlate) {
  13255. this.content = panel;
  13256. }
  13257. };
  13258. // Mesh association
  13259. HolographicButton.prototype._createNode = function (scene) {
  13260. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13261. width: 1.0,
  13262. height: 1.0,
  13263. depth: 0.08
  13264. }, scene);
  13265. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13266. width: 1.0,
  13267. height: 1.0,
  13268. depth: 0.08
  13269. }, scene);
  13270. this._frontPlate.parent = this._backPlate;
  13271. this._frontPlate.position.z = -0.08;
  13272. this._frontPlate.isPickable = false;
  13273. this._frontPlate.setEnabled(false);
  13274. this._textPlate = _super.prototype._createNode.call(this, scene);
  13275. this._textPlate.parent = this._backPlate;
  13276. this._textPlate.position.z = -0.08;
  13277. this._textPlate.isPickable = false;
  13278. return this._backPlate;
  13279. };
  13280. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13281. this._plateMaterial.emissiveTexture = facadeTexture;
  13282. this._plateMaterial.opacityTexture = facadeTexture;
  13283. };
  13284. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13285. var _this = this;
  13286. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13287. this._backMaterial.renderHoverLight = true;
  13288. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13289. if (pickedPoint) {
  13290. _this._backMaterial.hoverPosition = pickedPoint;
  13291. _this._backMaterial.hoverColor.a = 1.0;
  13292. }
  13293. else {
  13294. _this._backMaterial.hoverColor.a = 0;
  13295. }
  13296. });
  13297. };
  13298. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13299. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13300. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13301. this._frontMaterial.alpha = 0.5; // Additive
  13302. this._frontMaterial.renderBorders = true;
  13303. };
  13304. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13305. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13306. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13307. };
  13308. HolographicButton.prototype._affectMaterial = function (mesh) {
  13309. // Back
  13310. if (this._shareMaterials) {
  13311. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13312. this._createBackMaterial(mesh);
  13313. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13314. }
  13315. else {
  13316. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13317. }
  13318. // Front
  13319. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13320. this._createFrontMaterial(mesh);
  13321. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13322. }
  13323. else {
  13324. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13325. }
  13326. }
  13327. else {
  13328. this._createBackMaterial(mesh);
  13329. this._createFrontMaterial(mesh);
  13330. }
  13331. this._createPlateMaterial(mesh);
  13332. this._backPlate.material = this._backMaterial;
  13333. this._frontPlate.material = this._frontMaterial;
  13334. this._textPlate.material = this._plateMaterial;
  13335. this._rebuildContent();
  13336. };
  13337. /**
  13338. * Releases all associated resources
  13339. */
  13340. HolographicButton.prototype.dispose = function () {
  13341. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13342. this._disposeTooltip();
  13343. if (!this.shareMaterials) {
  13344. this._backMaterial.dispose();
  13345. this._frontMaterial.dispose();
  13346. this._plateMaterial.dispose();
  13347. if (this._pickedPointObserver) {
  13348. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13349. this._pickedPointObserver = null;
  13350. }
  13351. }
  13352. };
  13353. return HolographicButton;
  13354. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13355. /***/ }),
  13356. /***/ "./3D/controls/index.ts":
  13357. /*!******************************!*\
  13358. !*** ./3D/controls/index.ts ***!
  13359. \******************************/
  13360. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13361. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13362. "use strict";
  13363. __webpack_require__.r(__webpack_exports__);
  13364. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13366. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13368. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13370. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13372. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13374. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13376. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13378. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13380. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13382. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13384. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13386. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13388. /***/ }),
  13389. /***/ "./3D/controls/meshButton3D.ts":
  13390. /*!*************************************!*\
  13391. !*** ./3D/controls/meshButton3D.ts ***!
  13392. \*************************************/
  13393. /*! exports provided: MeshButton3D */
  13394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13395. "use strict";
  13396. __webpack_require__.r(__webpack_exports__);
  13397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13398. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13399. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13400. /**
  13401. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13402. */
  13403. var MeshButton3D = /** @class */ (function (_super) {
  13404. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13405. /**
  13406. * Creates a new 3D button based on a mesh
  13407. * @param mesh mesh to become a 3D button
  13408. * @param name defines the control name
  13409. */
  13410. function MeshButton3D(mesh, name) {
  13411. var _this = _super.call(this, name) || this;
  13412. _this._currentMesh = mesh;
  13413. /**
  13414. * Provides a default behavior on hover/out & up/down
  13415. * Override those function to create your own desired behavior specific to your mesh
  13416. */
  13417. _this.pointerEnterAnimation = function () {
  13418. if (!_this.mesh) {
  13419. return;
  13420. }
  13421. _this.mesh.scaling.scaleInPlace(1.1);
  13422. };
  13423. _this.pointerOutAnimation = function () {
  13424. if (!_this.mesh) {
  13425. return;
  13426. }
  13427. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13428. };
  13429. _this.pointerDownAnimation = function () {
  13430. if (!_this.mesh) {
  13431. return;
  13432. }
  13433. _this.mesh.scaling.scaleInPlace(0.95);
  13434. };
  13435. _this.pointerUpAnimation = function () {
  13436. if (!_this.mesh) {
  13437. return;
  13438. }
  13439. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13440. };
  13441. return _this;
  13442. }
  13443. MeshButton3D.prototype._getTypeName = function () {
  13444. return "MeshButton3D";
  13445. };
  13446. // Mesh association
  13447. MeshButton3D.prototype._createNode = function (scene) {
  13448. var _this = this;
  13449. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13450. mesh.metadata = _this;
  13451. });
  13452. return this._currentMesh;
  13453. };
  13454. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13455. };
  13456. return MeshButton3D;
  13457. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13458. /***/ }),
  13459. /***/ "./3D/controls/planePanel.ts":
  13460. /*!***********************************!*\
  13461. !*** ./3D/controls/planePanel.ts ***!
  13462. \***********************************/
  13463. /*! exports provided: PlanePanel */
  13464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13465. "use strict";
  13466. __webpack_require__.r(__webpack_exports__);
  13467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13469. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13470. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13471. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13472. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13473. /**
  13474. * Class used to create a container panel deployed on the surface of a plane
  13475. */
  13476. var PlanePanel = /** @class */ (function (_super) {
  13477. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13478. function PlanePanel() {
  13479. return _super !== null && _super.apply(this, arguments) || this;
  13480. }
  13481. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13482. var mesh = control.mesh;
  13483. if (!mesh) {
  13484. return;
  13485. }
  13486. control.position = nodePosition.clone();
  13487. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13488. target.copyFrom(nodePosition);
  13489. switch (this.orientation) {
  13490. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13491. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13492. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13493. mesh.lookAt(target);
  13494. break;
  13495. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13496. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13497. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13498. mesh.lookAt(target);
  13499. break;
  13500. }
  13501. };
  13502. return PlanePanel;
  13503. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13504. /***/ }),
  13505. /***/ "./3D/controls/scatterPanel.ts":
  13506. /*!*************************************!*\
  13507. !*** ./3D/controls/scatterPanel.ts ***!
  13508. \*************************************/
  13509. /*! exports provided: ScatterPanel */
  13510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13511. "use strict";
  13512. __webpack_require__.r(__webpack_exports__);
  13513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13514. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13515. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13516. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13517. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13518. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13519. /**
  13520. * Class used to create a container panel where items get randomized planar mapping
  13521. */
  13522. var ScatterPanel = /** @class */ (function (_super) {
  13523. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13524. function ScatterPanel() {
  13525. var _this = _super !== null && _super.apply(this, arguments) || this;
  13526. _this._iteration = 100.0;
  13527. return _this;
  13528. }
  13529. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13530. /**
  13531. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13532. */
  13533. get: function () {
  13534. return this._iteration;
  13535. },
  13536. set: function (value) {
  13537. var _this = this;
  13538. if (this._iteration === value) {
  13539. return;
  13540. }
  13541. this._iteration = value;
  13542. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13543. _this._arrangeChildren();
  13544. });
  13545. },
  13546. enumerable: true,
  13547. configurable: true
  13548. });
  13549. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13550. var mesh = control.mesh;
  13551. var newPos = this._scatterMapping(nodePosition);
  13552. if (!mesh) {
  13553. return;
  13554. }
  13555. switch (this.orientation) {
  13556. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13557. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13558. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13559. break;
  13560. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13561. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13562. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13563. break;
  13564. }
  13565. control.position = newPos;
  13566. };
  13567. ScatterPanel.prototype._scatterMapping = function (source) {
  13568. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13569. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13570. return source;
  13571. };
  13572. ScatterPanel.prototype._finalProcessing = function () {
  13573. var meshes = [];
  13574. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13575. var child = _a[_i];
  13576. if (!child.mesh) {
  13577. continue;
  13578. }
  13579. meshes.push(child.mesh);
  13580. }
  13581. for (var count = 0; count < this._iteration; count++) {
  13582. meshes.sort(function (a, b) {
  13583. var distance1 = a.position.lengthSquared();
  13584. var distance2 = b.position.lengthSquared();
  13585. if (distance1 < distance2) {
  13586. return 1;
  13587. }
  13588. else if (distance1 > distance2) {
  13589. return -1;
  13590. }
  13591. return 0;
  13592. });
  13593. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13594. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13595. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector2[0];
  13596. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13597. for (var i = 0; i < meshes.length - 1; i++) {
  13598. for (var j = i + 1; j < meshes.length; j++) {
  13599. if (i != j) {
  13600. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13601. // Ignore Z axis
  13602. difference2D.x = difference.x;
  13603. difference2D.y = difference.y;
  13604. var combinedRadius = cellSize;
  13605. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13606. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13607. distance -= minSeparation;
  13608. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13609. difference2D.normalize();
  13610. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13611. meshes[j].position.addInPlace(difference);
  13612. meshes[i].position.subtractInPlace(difference);
  13613. }
  13614. }
  13615. }
  13616. }
  13617. }
  13618. };
  13619. return ScatterPanel;
  13620. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13621. /***/ }),
  13622. /***/ "./3D/controls/spherePanel.ts":
  13623. /*!************************************!*\
  13624. !*** ./3D/controls/spherePanel.ts ***!
  13625. \************************************/
  13626. /*! exports provided: SpherePanel */
  13627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13628. "use strict";
  13629. __webpack_require__.r(__webpack_exports__);
  13630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13631. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13632. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13633. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13634. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13635. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13636. /**
  13637. * Class used to create a container panel deployed on the surface of a sphere
  13638. */
  13639. var SpherePanel = /** @class */ (function (_super) {
  13640. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13641. function SpherePanel() {
  13642. var _this = _super !== null && _super.apply(this, arguments) || this;
  13643. _this._radius = 5.0;
  13644. return _this;
  13645. }
  13646. Object.defineProperty(SpherePanel.prototype, "radius", {
  13647. /**
  13648. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13649. */
  13650. get: function () {
  13651. return this._radius;
  13652. },
  13653. set: function (value) {
  13654. var _this = this;
  13655. if (this._radius === value) {
  13656. return;
  13657. }
  13658. this._radius = value;
  13659. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13660. _this._arrangeChildren();
  13661. });
  13662. },
  13663. enumerable: true,
  13664. configurable: true
  13665. });
  13666. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13667. var mesh = control.mesh;
  13668. if (!mesh) {
  13669. return;
  13670. }
  13671. var newPos = this._sphericalMapping(nodePosition);
  13672. control.position = newPos;
  13673. switch (this.orientation) {
  13674. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13675. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13676. break;
  13677. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13678. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13679. break;
  13680. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13681. break;
  13682. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13683. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13684. break;
  13685. }
  13686. };
  13687. SpherePanel.prototype._sphericalMapping = function (source) {
  13688. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13689. var xAngle = (source.y / this._radius);
  13690. var yAngle = -(source.x / this._radius);
  13691. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13692. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13693. };
  13694. return SpherePanel;
  13695. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13696. /***/ }),
  13697. /***/ "./3D/controls/stackPanel3D.ts":
  13698. /*!*************************************!*\
  13699. !*** ./3D/controls/stackPanel3D.ts ***!
  13700. \*************************************/
  13701. /*! exports provided: StackPanel3D */
  13702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13703. "use strict";
  13704. __webpack_require__.r(__webpack_exports__);
  13705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13706. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13707. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13708. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13709. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13710. /**
  13711. * Class used to create a stack panel in 3D on XY plane
  13712. */
  13713. var StackPanel3D = /** @class */ (function (_super) {
  13714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13715. /**
  13716. * Creates new StackPanel
  13717. * @param isVertical
  13718. */
  13719. function StackPanel3D(isVertical) {
  13720. if (isVertical === void 0) { isVertical = false; }
  13721. var _this = _super.call(this) || this;
  13722. _this._isVertical = false;
  13723. /**
  13724. * Gets or sets the distance between elements
  13725. */
  13726. _this.margin = 0.1;
  13727. _this._isVertical = isVertical;
  13728. return _this;
  13729. }
  13730. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13731. /**
  13732. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13733. */
  13734. get: function () {
  13735. return this._isVertical;
  13736. },
  13737. set: function (value) {
  13738. var _this = this;
  13739. if (this._isVertical === value) {
  13740. return;
  13741. }
  13742. this._isVertical = value;
  13743. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13744. _this._arrangeChildren();
  13745. });
  13746. },
  13747. enumerable: true,
  13748. configurable: true
  13749. });
  13750. StackPanel3D.prototype._arrangeChildren = function () {
  13751. var width = 0;
  13752. var height = 0;
  13753. var controlCount = 0;
  13754. var extendSizes = [];
  13755. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13756. // Measure
  13757. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13758. var child = _a[_i];
  13759. if (!child.mesh) {
  13760. continue;
  13761. }
  13762. controlCount++;
  13763. child.mesh.computeWorldMatrix(true);
  13764. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13765. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13766. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13767. extendSizes.push(extendSize);
  13768. if (this._isVertical) {
  13769. height += extendSize.y;
  13770. }
  13771. else {
  13772. width += extendSize.x;
  13773. }
  13774. }
  13775. if (this._isVertical) {
  13776. height += (controlCount - 1) * this.margin / 2;
  13777. }
  13778. else {
  13779. width += (controlCount - 1) * this.margin / 2;
  13780. }
  13781. // Arrange
  13782. var offset;
  13783. if (this._isVertical) {
  13784. offset = -height;
  13785. }
  13786. else {
  13787. offset = -width;
  13788. }
  13789. var index = 0;
  13790. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13791. var child = _c[_b];
  13792. if (!child.mesh) {
  13793. continue;
  13794. }
  13795. controlCount--;
  13796. var extendSize = extendSizes[index++];
  13797. if (this._isVertical) {
  13798. child.position.y = offset + extendSize.y;
  13799. child.position.x = 0;
  13800. offset += extendSize.y * 2;
  13801. }
  13802. else {
  13803. child.position.x = offset + extendSize.x;
  13804. child.position.y = 0;
  13805. offset += extendSize.x * 2;
  13806. }
  13807. offset += (controlCount > 0 ? this.margin : 0);
  13808. }
  13809. };
  13810. return StackPanel3D;
  13811. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13812. /***/ }),
  13813. /***/ "./3D/controls/volumeBasedPanel.ts":
  13814. /*!*****************************************!*\
  13815. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13816. \*****************************************/
  13817. /*! exports provided: VolumeBasedPanel */
  13818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13819. "use strict";
  13820. __webpack_require__.r(__webpack_exports__);
  13821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13822. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13823. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13824. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13825. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13826. /**
  13827. * Abstract class used to create a container panel deployed on the surface of a volume
  13828. */
  13829. var VolumeBasedPanel = /** @class */ (function (_super) {
  13830. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13831. /**
  13832. * Creates new VolumeBasedPanel
  13833. */
  13834. function VolumeBasedPanel() {
  13835. var _this = _super.call(this) || this;
  13836. _this._columns = 10;
  13837. _this._rows = 0;
  13838. _this._rowThenColum = true;
  13839. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13840. /**
  13841. * Gets or sets the distance between elements
  13842. */
  13843. _this.margin = 0;
  13844. return _this;
  13845. }
  13846. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13847. /**
  13848. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13849. * | Value | Type | Description |
  13850. * | ----- | ----------------------------------- | ----------- |
  13851. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  13852. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  13853. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  13854. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  13855. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  13856. */
  13857. get: function () {
  13858. return this._orientation;
  13859. },
  13860. set: function (value) {
  13861. var _this = this;
  13862. if (this._orientation === value) {
  13863. return;
  13864. }
  13865. this._orientation = value;
  13866. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13867. _this._arrangeChildren();
  13868. });
  13869. },
  13870. enumerable: true,
  13871. configurable: true
  13872. });
  13873. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  13874. /**
  13875. * Gets or sets the number of columns requested (10 by default).
  13876. * The panel will automatically compute the number of rows based on number of child controls.
  13877. */
  13878. get: function () {
  13879. return this._columns;
  13880. },
  13881. set: function (value) {
  13882. var _this = this;
  13883. if (this._columns === value) {
  13884. return;
  13885. }
  13886. this._columns = value;
  13887. this._rowThenColum = true;
  13888. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13889. _this._arrangeChildren();
  13890. });
  13891. },
  13892. enumerable: true,
  13893. configurable: true
  13894. });
  13895. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  13896. /**
  13897. * Gets or sets a the number of rows requested.
  13898. * The panel will automatically compute the number of columns based on number of child controls.
  13899. */
  13900. get: function () {
  13901. return this._rows;
  13902. },
  13903. set: function (value) {
  13904. var _this = this;
  13905. if (this._rows === value) {
  13906. return;
  13907. }
  13908. this._rows = value;
  13909. this._rowThenColum = false;
  13910. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13911. _this._arrangeChildren();
  13912. });
  13913. },
  13914. enumerable: true,
  13915. configurable: true
  13916. });
  13917. VolumeBasedPanel.prototype._arrangeChildren = function () {
  13918. this._cellWidth = 0;
  13919. this._cellHeight = 0;
  13920. var rows = 0;
  13921. var columns = 0;
  13922. var controlCount = 0;
  13923. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13924. // Measure
  13925. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13926. var child = _a[_i];
  13927. if (!child.mesh) {
  13928. continue;
  13929. }
  13930. controlCount++;
  13931. child.mesh.computeWorldMatrix(true);
  13932. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  13933. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  13934. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13935. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  13936. boundingBox.max.subtractToRef(boundingBox.min, diff);
  13937. diff.scaleInPlace(0.5);
  13938. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  13939. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  13940. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  13941. }
  13942. this._cellWidth += this.margin * 2;
  13943. this._cellHeight += this.margin * 2;
  13944. // Arrange
  13945. if (this._rowThenColum) {
  13946. columns = this._columns;
  13947. rows = Math.ceil(controlCount / this._columns);
  13948. }
  13949. else {
  13950. rows = this._rows;
  13951. columns = Math.ceil(controlCount / this._rows);
  13952. }
  13953. var startOffsetX = (columns * 0.5) * this._cellWidth;
  13954. var startOffsetY = (rows * 0.5) * this._cellHeight;
  13955. var nodeGrid = [];
  13956. var cellCounter = 0;
  13957. if (this._rowThenColum) {
  13958. for (var r = 0; r < rows; r++) {
  13959. for (var c = 0; c < columns; c++) {
  13960. nodeGrid.push(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"]((c * this._cellWidth) - startOffsetX + this._cellWidth / 2, (r * this._cellHeight) - startOffsetY + this._cellHeight / 2, 0));
  13961. cellCounter++;
  13962. if (cellCounter > controlCount) {
  13963. break;
  13964. }
  13965. }
  13966. }
  13967. }
  13968. else {
  13969. for (var c = 0; c < columns; c++) {
  13970. for (var r = 0; r < rows; r++) {
  13971. nodeGrid.push(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"]((c * this._cellWidth) - startOffsetX + this._cellWidth / 2, (r * this._cellHeight) - startOffsetY + this._cellHeight / 2, 0));
  13972. cellCounter++;
  13973. if (cellCounter > controlCount) {
  13974. break;
  13975. }
  13976. }
  13977. }
  13978. }
  13979. cellCounter = 0;
  13980. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13981. var child = _c[_b];
  13982. if (!child.mesh) {
  13983. continue;
  13984. }
  13985. this._mapGridNode(child, nodeGrid[cellCounter]);
  13986. cellCounter++;
  13987. }
  13988. this._finalProcessing();
  13989. };
  13990. /** Child classes can implement this function to provide additional processing */
  13991. VolumeBasedPanel.prototype._finalProcessing = function () {
  13992. };
  13993. return VolumeBasedPanel;
  13994. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13995. /***/ }),
  13996. /***/ "./3D/gui3DManager.ts":
  13997. /*!****************************!*\
  13998. !*** ./3D/gui3DManager.ts ***!
  13999. \****************************/
  14000. /*! exports provided: GUI3DManager */
  14001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14002. "use strict";
  14003. __webpack_require__.r(__webpack_exports__);
  14004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14005. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  14006. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14007. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14008. /**
  14009. * Class used to manage 3D user interface
  14010. * @see http://doc.babylonjs.com/how_to/gui3d
  14011. */
  14012. var GUI3DManager = /** @class */ (function () {
  14013. /**
  14014. * Creates a new GUI3DManager
  14015. * @param scene
  14016. */
  14017. function GUI3DManager(scene) {
  14018. var _this = this;
  14019. /** @hidden */
  14020. this._lastControlOver = {};
  14021. /** @hidden */
  14022. this._lastControlDown = {};
  14023. /**
  14024. * Observable raised when the point picked by the pointer events changed
  14025. */
  14026. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14027. // Shared resources
  14028. /** @hidden */
  14029. this._sharedMaterials = {};
  14030. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14031. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14032. _this._sceneDisposeObserver = null;
  14033. _this._utilityLayer = null;
  14034. _this.dispose();
  14035. });
  14036. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14037. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14038. this._utilityLayer.pickUtilitySceneFirst = false;
  14039. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14040. return mesh && mesh.metadata && mesh.metadata._node;
  14041. };
  14042. // Root
  14043. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14044. this._rootContainer._host = this;
  14045. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14046. // Events
  14047. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14048. _this._handlePointerOut(pointerId, true);
  14049. });
  14050. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14051. _this._doPicking(pi);
  14052. });
  14053. // Scene
  14054. this._utilityLayer.utilityLayerScene.autoClear = false;
  14055. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14056. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14057. }
  14058. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14059. /** Gets the hosting scene */
  14060. get: function () {
  14061. return this._scene;
  14062. },
  14063. enumerable: true,
  14064. configurable: true
  14065. });
  14066. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14067. /** Gets associated utility layer */
  14068. get: function () {
  14069. return this._utilityLayer;
  14070. },
  14071. enumerable: true,
  14072. configurable: true
  14073. });
  14074. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14075. var previousControlOver = this._lastControlOver[pointerId];
  14076. if (previousControlOver) {
  14077. previousControlOver._onPointerOut(previousControlOver);
  14078. delete this._lastControlOver[pointerId];
  14079. }
  14080. if (isPointerUp) {
  14081. if (this._lastControlDown[pointerId]) {
  14082. this._lastControlDown[pointerId].forcePointerUp();
  14083. delete this._lastControlDown[pointerId];
  14084. }
  14085. }
  14086. this.onPickedPointChangedObservable.notifyObservers(null);
  14087. };
  14088. GUI3DManager.prototype._doPicking = function (pi) {
  14089. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14090. return false;
  14091. }
  14092. var pointerEvent = (pi.event);
  14093. var pointerId = pointerEvent.pointerId || 0;
  14094. var buttonIndex = pointerEvent.button;
  14095. var pickingInfo = pi.pickInfo;
  14096. if (!pickingInfo || !pickingInfo.hit) {
  14097. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14098. return false;
  14099. }
  14100. var control = (pickingInfo.pickedMesh.metadata);
  14101. if (pickingInfo.pickedPoint) {
  14102. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14103. }
  14104. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14105. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14106. if (this._lastControlOver[pointerId]) {
  14107. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14108. }
  14109. delete this._lastControlOver[pointerId];
  14110. }
  14111. }
  14112. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14113. if (this._lastControlDown[pointerEvent.pointerId]) {
  14114. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14115. delete this._lastControlDown[pointerEvent.pointerId];
  14116. }
  14117. if (pointerEvent.pointerType === "touch") {
  14118. this._handlePointerOut(pointerId, false);
  14119. }
  14120. }
  14121. return true;
  14122. };
  14123. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14124. /**
  14125. * Gets the root container
  14126. */
  14127. get: function () {
  14128. return this._rootContainer;
  14129. },
  14130. enumerable: true,
  14131. configurable: true
  14132. });
  14133. /**
  14134. * Gets a boolean indicating if the given control is in the root child list
  14135. * @param control defines the control to check
  14136. * @returns true if the control is in the root child list
  14137. */
  14138. GUI3DManager.prototype.containsControl = function (control) {
  14139. return this._rootContainer.containsControl(control);
  14140. };
  14141. /**
  14142. * Adds a control to the root child list
  14143. * @param control defines the control to add
  14144. * @returns the current manager
  14145. */
  14146. GUI3DManager.prototype.addControl = function (control) {
  14147. this._rootContainer.addControl(control);
  14148. return this;
  14149. };
  14150. /**
  14151. * Removes a control from the root child list
  14152. * @param control defines the control to remove
  14153. * @returns the current container
  14154. */
  14155. GUI3DManager.prototype.removeControl = function (control) {
  14156. this._rootContainer.removeControl(control);
  14157. return this;
  14158. };
  14159. /**
  14160. * Releases all associated resources
  14161. */
  14162. GUI3DManager.prototype.dispose = function () {
  14163. this._rootContainer.dispose();
  14164. for (var materialName in this._sharedMaterials) {
  14165. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14166. continue;
  14167. }
  14168. this._sharedMaterials[materialName].dispose();
  14169. }
  14170. this._sharedMaterials = {};
  14171. if (this._pointerOutObserver && this._utilityLayer) {
  14172. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14173. this._pointerOutObserver = null;
  14174. }
  14175. this.onPickedPointChangedObservable.clear();
  14176. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14177. if (utilityLayerScene) {
  14178. if (this._pointerObserver) {
  14179. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14180. this._pointerObserver = null;
  14181. }
  14182. }
  14183. if (this._scene) {
  14184. if (this._sceneDisposeObserver) {
  14185. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14186. this._sceneDisposeObserver = null;
  14187. }
  14188. }
  14189. if (this._utilityLayer) {
  14190. this._utilityLayer.dispose();
  14191. }
  14192. };
  14193. return GUI3DManager;
  14194. }());
  14195. /***/ }),
  14196. /***/ "./3D/index.ts":
  14197. /*!*********************!*\
  14198. !*** ./3D/index.ts ***!
  14199. \*********************/
  14200. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14201. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14202. "use strict";
  14203. __webpack_require__.r(__webpack_exports__);
  14204. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14217. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14220. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14222. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14224. /***/ }),
  14225. /***/ "./3D/materials/fluentMaterial.ts":
  14226. /*!****************************************!*\
  14227. !*** ./3D/materials/fluentMaterial.ts ***!
  14228. \****************************************/
  14229. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14230. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14231. "use strict";
  14232. __webpack_require__.r(__webpack_exports__);
  14233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14235. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14236. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  14237. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14238. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14239. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14240. /** @hidden */
  14241. var FluentMaterialDefines = /** @class */ (function (_super) {
  14242. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14243. function FluentMaterialDefines() {
  14244. var _this = _super.call(this) || this;
  14245. _this.INNERGLOW = false;
  14246. _this.BORDER = false;
  14247. _this.HOVERLIGHT = false;
  14248. _this.TEXTURE = false;
  14249. _this.rebuild();
  14250. return _this;
  14251. }
  14252. return FluentMaterialDefines;
  14253. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14254. /**
  14255. * Class used to render controls with fluent desgin
  14256. */
  14257. var FluentMaterial = /** @class */ (function (_super) {
  14258. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14259. /**
  14260. * Creates a new Fluent material
  14261. * @param name defines the name of the material
  14262. * @param scene defines the hosting scene
  14263. */
  14264. function FluentMaterial(name, scene) {
  14265. var _this = _super.call(this, name, scene) || this;
  14266. /**
  14267. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14268. */
  14269. _this.innerGlowColorIntensity = 0.5;
  14270. /**
  14271. * Gets or sets the inner glow color (white by default)
  14272. */
  14273. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14274. /**
  14275. * Gets or sets alpha value (default is 1.0)
  14276. */
  14277. _this.alpha = 1.0;
  14278. /**
  14279. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14280. */
  14281. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14282. /**
  14283. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14284. */
  14285. _this.renderBorders = false;
  14286. /**
  14287. * Gets or sets border width (default is 0.5)
  14288. */
  14289. _this.borderWidth = 0.5;
  14290. /**
  14291. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14292. */
  14293. _this.edgeSmoothingValue = 0.02;
  14294. /**
  14295. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14296. */
  14297. _this.borderMinValue = 0.1;
  14298. /**
  14299. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14300. */
  14301. _this.renderHoverLight = false;
  14302. /**
  14303. * Gets or sets the radius used to render the hover light (default is 1.0)
  14304. */
  14305. _this.hoverRadius = 1.0;
  14306. /**
  14307. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14308. */
  14309. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14310. /**
  14311. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14312. */
  14313. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14314. return _this;
  14315. }
  14316. FluentMaterial.prototype.needAlphaBlending = function () {
  14317. return this.alpha !== 1.0;
  14318. };
  14319. FluentMaterial.prototype.needAlphaTesting = function () {
  14320. return false;
  14321. };
  14322. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14323. return null;
  14324. };
  14325. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14326. if (this.isFrozen) {
  14327. if (this._wasPreviouslyReady && subMesh.effect) {
  14328. return true;
  14329. }
  14330. }
  14331. if (!subMesh._materialDefines) {
  14332. subMesh._materialDefines = new FluentMaterialDefines();
  14333. }
  14334. var scene = this.getScene();
  14335. var defines = subMesh._materialDefines;
  14336. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14337. if (defines._renderId === scene.getRenderId()) {
  14338. return true;
  14339. }
  14340. }
  14341. if (defines._areTexturesDirty) {
  14342. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14343. defines.BORDER = this.renderBorders;
  14344. defines.HOVERLIGHT = this.renderHoverLight;
  14345. if (this._albedoTexture) {
  14346. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14347. return false;
  14348. }
  14349. else {
  14350. defines.TEXTURE = true;
  14351. }
  14352. }
  14353. else {
  14354. defines.TEXTURE = false;
  14355. }
  14356. }
  14357. var engine = scene.getEngine();
  14358. // Get correct effect
  14359. if (defines.isDirty) {
  14360. defines.markAsProcessed();
  14361. scene.resetCachedMaterial();
  14362. //Attributes
  14363. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14364. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14365. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14366. var shaderName = "fluent";
  14367. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14368. "hoverColor", "hoverPosition", "hoverRadius"
  14369. ];
  14370. var samplers = ["albedoSampler"];
  14371. var uniformBuffers = new Array();
  14372. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14373. uniformsNames: uniforms,
  14374. uniformBuffersNames: uniformBuffers,
  14375. samplers: samplers,
  14376. defines: defines,
  14377. maxSimultaneousLights: 4
  14378. });
  14379. var join = defines.toString();
  14380. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14381. attributes: attribs,
  14382. uniformsNames: uniforms,
  14383. uniformBuffersNames: uniformBuffers,
  14384. samplers: samplers,
  14385. defines: join,
  14386. fallbacks: null,
  14387. onCompiled: this.onCompiled,
  14388. onError: this.onError,
  14389. indexParameters: { maxSimultaneousLights: 4 }
  14390. }, engine));
  14391. }
  14392. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14393. return false;
  14394. }
  14395. defines._renderId = scene.getRenderId();
  14396. this._wasPreviouslyReady = true;
  14397. return true;
  14398. };
  14399. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14400. var scene = this.getScene();
  14401. var defines = subMesh._materialDefines;
  14402. if (!defines) {
  14403. return;
  14404. }
  14405. var effect = subMesh.effect;
  14406. if (!effect) {
  14407. return;
  14408. }
  14409. this._activeEffect = effect;
  14410. // Matrices
  14411. this.bindOnlyWorldMatrix(world);
  14412. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14413. if (this._mustRebind(scene, effect)) {
  14414. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14415. if (defines.INNERGLOW) {
  14416. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14417. }
  14418. if (defines.BORDER) {
  14419. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14420. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14421. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14422. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14423. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14424. }
  14425. if (defines.HOVERLIGHT) {
  14426. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14427. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14428. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14429. }
  14430. if (defines.TEXTURE) {
  14431. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14432. }
  14433. }
  14434. this._afterBind(mesh, this._activeEffect);
  14435. };
  14436. FluentMaterial.prototype.getActiveTextures = function () {
  14437. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14438. return activeTextures;
  14439. };
  14440. FluentMaterial.prototype.hasTexture = function (texture) {
  14441. if (_super.prototype.hasTexture.call(this, texture)) {
  14442. return true;
  14443. }
  14444. return false;
  14445. };
  14446. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14447. _super.prototype.dispose.call(this, forceDisposeEffect);
  14448. };
  14449. FluentMaterial.prototype.clone = function (name) {
  14450. var _this = this;
  14451. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14452. };
  14453. FluentMaterial.prototype.serialize = function () {
  14454. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14455. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14456. return serializationObject;
  14457. };
  14458. FluentMaterial.prototype.getClassName = function () {
  14459. return "FluentMaterial";
  14460. };
  14461. // Statics
  14462. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14463. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14464. };
  14465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14466. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14467. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14468. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14469. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14470. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14471. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14472. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14473. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14474. ], FluentMaterial.prototype, "alpha", void 0);
  14475. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14476. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14477. ], FluentMaterial.prototype, "albedoColor", void 0);
  14478. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14479. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14480. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14481. ], FluentMaterial.prototype, "renderBorders", void 0);
  14482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14483. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14484. ], FluentMaterial.prototype, "borderWidth", void 0);
  14485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14486. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14487. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14489. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14490. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14492. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14493. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14494. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14495. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14496. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14497. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14498. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14499. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14500. ], FluentMaterial.prototype, "hoverColor", void 0);
  14501. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14502. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14503. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14504. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14505. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14506. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14507. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14508. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14509. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14510. return FluentMaterial;
  14511. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14512. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14513. /***/ }),
  14514. /***/ "./3D/materials/index.ts":
  14515. /*!*******************************!*\
  14516. !*** ./3D/materials/index.ts ***!
  14517. \*******************************/
  14518. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14520. "use strict";
  14521. __webpack_require__.r(__webpack_exports__);
  14522. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14525. /***/ }),
  14526. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14527. /*!*************************************************!*\
  14528. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14529. \*************************************************/
  14530. /*! exports provided: fluentPixelShader */
  14531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14532. "use strict";
  14533. __webpack_require__.r(__webpack_exports__);
  14534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14535. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14536. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14537. var name = 'fluentPixelShader';
  14538. var shader = "precision highp float;\nvarying vec2 vUV;\nuniform vec4 albedoColor;\n#ifdef INNERGLOW\nuniform vec4 innerGlowColor;\n#endif\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float edgeSmoothingValue;\nuniform float borderMinValue;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\nuniform vec3 hoverPosition;\nuniform vec4 hoverColor;\nuniform float hoverRadius;\n#endif\n#ifdef TEXTURE\nuniform sampler2D albedoSampler;\n#endif\nvoid main(void) {\nvec3 albedo=albedoColor.rgb;\nfloat alpha=albedoColor.a;\n#ifdef TEXTURE\nalbedo=texture2D(albedoSampler,vUV).rgb;\n#endif\n#ifdef HOVERLIGHT\nfloat pointToHover=(1.0-clamp(length(hoverPosition-worldPosition)/hoverRadius,0.,1.))*hoverColor.a;\nalbedo=clamp(albedo+hoverColor.rgb*pointToHover,0.,1.);\n#else\nfloat pointToHover=1.0;\n#endif\n#ifdef BORDER\nfloat borderPower=10.0;\nfloat inverseBorderPower=1.0/borderPower;\nvec3 borderColor=albedo*borderPower;\nvec2 distanceToEdge;\ndistanceToEdge.x=abs(vUV.x-0.5)*2.0;\ndistanceToEdge.y=abs(vUV.y-0.5)*2.0;\nfloat borderValue=max(smoothstep(scaleInfo.x-edgeSmoothingValue,scaleInfo.x+edgeSmoothingValue,distanceToEdge.x),\nsmoothstep(scaleInfo.y-edgeSmoothingValue,scaleInfo.y+edgeSmoothingValue,distanceToEdge.y));\nborderColor=borderColor*borderValue*max(borderMinValue*inverseBorderPower,pointToHover);\nalbedo+=borderColor;\nalpha=max(alpha,borderValue);\n#endif\n#ifdef INNERGLOW\n\nvec2 uvGlow=(vUV-vec2(0.5,0.5))*(innerGlowColor.a*2.0);\nuvGlow=uvGlow*uvGlow;\nuvGlow=uvGlow*uvGlow;\nalbedo+=mix(vec3(0.0,0.0,0.0),innerGlowColor.rgb,uvGlow.x+uvGlow.y);\n#endif\ngl_FragColor=vec4(albedo,alpha);\n}";
  14539. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14540. /** @hidden */
  14541. var fluentPixelShader = { name: name, shader: shader };
  14542. /***/ }),
  14543. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14544. /*!***********************************************!*\
  14545. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14546. \***********************************************/
  14547. /*! exports provided: fluentVertexShader */
  14548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14549. "use strict";
  14550. __webpack_require__.r(__webpack_exports__);
  14551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14552. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14553. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14554. var name = 'fluentVertexShader';
  14555. var shader = "precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n\nuniform mat4 world;\nuniform mat4 viewProjection;\nvarying vec2 vUV;\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float borderWidth;\nuniform vec3 scaleFactor;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\n#endif\nvoid main(void) {\nvUV=uv;\n#ifdef BORDER\nvec3 scale=scaleFactor;\nfloat minScale=min(min(scale.x,scale.y),scale.z);\nfloat maxScale=max(max(scale.x,scale.y),scale.z);\nfloat minOverMiddleScale=minScale/(scale.x+scale.y+scale.z-minScale-maxScale);\nfloat areaYZ=scale.y*scale.z;\nfloat areaXZ=scale.x*scale.z;\nfloat areaXY=scale.x*scale.y;\nfloat scaledBorderWidth=borderWidth;\nif (abs(normal.x) == 1.0)\n{\nscale.x=scale.y;\nscale.y=scale.z;\nif (areaYZ>areaXZ && areaYZ>areaXY)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse if (abs(normal.y) == 1.0)\n{\nscale.x=scale.z;\nif (areaXZ>areaXY && areaXZ>areaYZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse\n{\nif (areaXY>areaYZ && areaXY>areaXZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nfloat scaleRatio=min(scale.x,scale.y)/max(scale.x,scale.y);\nif (scale.x>scale.y)\n{\nscaleInfo.x=1.0-(scaledBorderWidth*scaleRatio);\nscaleInfo.y=1.0-scaledBorderWidth;\n}\nelse\n{\nscaleInfo.x=1.0-scaledBorderWidth;\nscaleInfo.y=1.0-(scaledBorderWidth*scaleRatio);\n}\n#endif\nvec4 worldPos=world*vec4(position,1.0);\n#ifdef HOVERLIGHT\nworldPosition=worldPos.xyz;\n#endif\ngl_Position=viewProjection*worldPos;\n}\n";
  14556. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14557. /** @hidden */
  14558. var fluentVertexShader = { name: name, shader: shader };
  14559. /***/ }),
  14560. /***/ "./3D/vector3WithInfo.ts":
  14561. /*!*******************************!*\
  14562. !*** ./3D/vector3WithInfo.ts ***!
  14563. \*******************************/
  14564. /*! exports provided: Vector3WithInfo */
  14565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14566. "use strict";
  14567. __webpack_require__.r(__webpack_exports__);
  14568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14569. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14570. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  14571. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14572. /**
  14573. * Class used to transport Vector3 information for pointer events
  14574. */
  14575. var Vector3WithInfo = /** @class */ (function (_super) {
  14576. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14577. /**
  14578. * Creates a new Vector3WithInfo
  14579. * @param source defines the vector3 data to transport
  14580. * @param buttonIndex defines the current mouse button index
  14581. */
  14582. function Vector3WithInfo(source,
  14583. /** defines the current mouse button index */
  14584. buttonIndex) {
  14585. if (buttonIndex === void 0) { buttonIndex = 0; }
  14586. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14587. _this.buttonIndex = buttonIndex;
  14588. return _this;
  14589. }
  14590. return Vector3WithInfo;
  14591. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14592. /***/ }),
  14593. /***/ "./index.ts":
  14594. /*!******************!*\
  14595. !*** ./index.ts ***!
  14596. \******************/
  14597. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14599. "use strict";
  14600. __webpack_require__.r(__webpack_exports__);
  14601. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14640. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14657. /***/ }),
  14658. /***/ "./legacy/legacy.ts":
  14659. /*!**************************!*\
  14660. !*** ./legacy/legacy.ts ***!
  14661. \**************************/
  14662. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14664. "use strict";
  14665. __webpack_require__.r(__webpack_exports__);
  14666. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14721. /**
  14722. * Legacy support, defining window.BABYLON.GUI (global variable).
  14723. *
  14724. * This is the entry point for the UMD module.
  14725. * The entry point for a future ESM package should be index.ts
  14726. */
  14727. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14728. if (typeof globalObject !== "undefined") {
  14729. globalObject.BABYLON = globalObject.BABYLON || {};
  14730. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14731. }
  14732. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14733. /***/ }),
  14734. /***/ "babylonjs/Misc/observable":
  14735. /*!****************************************************************************************************!*\
  14736. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14737. \****************************************************************************************************/
  14738. /*! no static exports found */
  14739. /***/ (function(module, exports) {
  14740. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;
  14741. /***/ })
  14742. /******/ });
  14743. });
  14744. //# sourceMappingURL=babylon.gui.js.map