babylon.gui.js 672 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553
  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__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!*****************************************************************!*\
  100. !*** C:/Dev/Babylon/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");
  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");
  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");
  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");
  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");
  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");
  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");
  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, ScrollBar, 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 _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6705. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6707. /***/ }),
  6708. /***/ "./2D/controls/inputPassword.ts":
  6709. /*!**************************************!*\
  6710. !*** ./2D/controls/inputPassword.ts ***!
  6711. \**************************************/
  6712. /*! exports provided: InputPassword */
  6713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6714. "use strict";
  6715. __webpack_require__.r(__webpack_exports__);
  6716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6717. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6718. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6719. /**
  6720. * Class used to create a password control
  6721. */
  6722. var InputPassword = /** @class */ (function (_super) {
  6723. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6724. function InputPassword() {
  6725. return _super !== null && _super.apply(this, arguments) || this;
  6726. }
  6727. InputPassword.prototype._beforeRenderText = function (text) {
  6728. var txt = "";
  6729. for (var i = 0; i < text.length; i++) {
  6730. txt += "\u2022";
  6731. }
  6732. return txt;
  6733. };
  6734. return InputPassword;
  6735. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6736. /***/ }),
  6737. /***/ "./2D/controls/inputText.ts":
  6738. /*!**********************************!*\
  6739. !*** ./2D/controls/inputText.ts ***!
  6740. \**********************************/
  6741. /*! exports provided: InputText */
  6742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6743. "use strict";
  6744. __webpack_require__.r(__webpack_exports__);
  6745. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6746. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6747. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs");
  6748. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6749. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6750. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6751. /**
  6752. * Class used to create input text control
  6753. */
  6754. var InputText = /** @class */ (function (_super) {
  6755. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6756. /**
  6757. * Creates a new InputText
  6758. * @param name defines the control name
  6759. * @param text defines the text of the control
  6760. */
  6761. function InputText(name, text) {
  6762. if (text === void 0) { text = ""; }
  6763. var _this = _super.call(this, name) || this;
  6764. _this.name = name;
  6765. _this._text = "";
  6766. _this._placeholderText = "";
  6767. _this._background = "#222222";
  6768. _this._focusedBackground = "#000000";
  6769. _this._focusedColor = "white";
  6770. _this._placeholderColor = "gray";
  6771. _this._thickness = 1;
  6772. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6773. _this._autoStretchWidth = true;
  6774. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6775. _this._isFocused = false;
  6776. _this._blinkIsEven = false;
  6777. _this._cursorOffset = 0;
  6778. _this._deadKey = false;
  6779. _this._addKey = true;
  6780. _this._currentKey = "";
  6781. _this._isTextHighlightOn = false;
  6782. _this._textHighlightColor = "#d5e0ff";
  6783. _this._highligherOpacity = 0.4;
  6784. _this._highlightedText = "";
  6785. _this._startHighlightIndex = 0;
  6786. _this._endHighlightIndex = 0;
  6787. _this._cursorIndex = -1;
  6788. _this._onFocusSelectAll = false;
  6789. _this._isPointerDown = false;
  6790. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6791. _this.promptMessage = "Please enter text:";
  6792. /** Observable raised when the text changes */
  6793. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6794. /** Observable raised just before an entered character is to be added */
  6795. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6796. /** Observable raised when the control gets the focus */
  6797. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6798. /** Observable raised when the control loses the focus */
  6799. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6800. /**Observable raised when the text is highlighted */
  6801. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6802. /**Observable raised when copy event is triggered */
  6803. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6804. /** Observable raised when cut event is triggered */
  6805. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6806. /** Observable raised when paste event is triggered */
  6807. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6808. /** Observable raised when a key event was processed */
  6809. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6810. _this.text = text;
  6811. _this.isPointerBlocker = true;
  6812. return _this;
  6813. }
  6814. Object.defineProperty(InputText.prototype, "maxWidth", {
  6815. /** Gets or sets the maximum width allowed by the control */
  6816. get: function () {
  6817. return this._maxWidth.toString(this._host);
  6818. },
  6819. set: function (value) {
  6820. if (this._maxWidth.toString(this._host) === value) {
  6821. return;
  6822. }
  6823. if (this._maxWidth.fromString(value)) {
  6824. this._markAsDirty();
  6825. }
  6826. },
  6827. enumerable: true,
  6828. configurable: true
  6829. });
  6830. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6831. /** Gets the maximum width allowed by the control in pixels */
  6832. get: function () {
  6833. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6834. },
  6835. enumerable: true,
  6836. configurable: true
  6837. });
  6838. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6839. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6840. get: function () {
  6841. return this._highligherOpacity;
  6842. },
  6843. set: function (value) {
  6844. if (this._highligherOpacity === value) {
  6845. return;
  6846. }
  6847. this._highligherOpacity = value;
  6848. this._markAsDirty();
  6849. },
  6850. enumerable: true,
  6851. configurable: true
  6852. });
  6853. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6854. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6855. get: function () {
  6856. return this._onFocusSelectAll;
  6857. },
  6858. set: function (value) {
  6859. if (this._onFocusSelectAll === value) {
  6860. return;
  6861. }
  6862. this._onFocusSelectAll = value;
  6863. this._markAsDirty();
  6864. },
  6865. enumerable: true,
  6866. configurable: true
  6867. });
  6868. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6869. /** Gets or sets the text hightlight color */
  6870. get: function () {
  6871. return this._textHighlightColor;
  6872. },
  6873. set: function (value) {
  6874. if (this._textHighlightColor === value) {
  6875. return;
  6876. }
  6877. this._textHighlightColor = value;
  6878. this._markAsDirty();
  6879. },
  6880. enumerable: true,
  6881. configurable: true
  6882. });
  6883. Object.defineProperty(InputText.prototype, "margin", {
  6884. /** Gets or sets control margin */
  6885. get: function () {
  6886. return this._margin.toString(this._host);
  6887. },
  6888. set: function (value) {
  6889. if (this._margin.toString(this._host) === value) {
  6890. return;
  6891. }
  6892. if (this._margin.fromString(value)) {
  6893. this._markAsDirty();
  6894. }
  6895. },
  6896. enumerable: true,
  6897. configurable: true
  6898. });
  6899. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6900. /** Gets control margin in pixels */
  6901. get: function () {
  6902. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6903. },
  6904. enumerable: true,
  6905. configurable: true
  6906. });
  6907. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6908. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6909. get: function () {
  6910. return this._autoStretchWidth;
  6911. },
  6912. set: function (value) {
  6913. if (this._autoStretchWidth === value) {
  6914. return;
  6915. }
  6916. this._autoStretchWidth = value;
  6917. this._markAsDirty();
  6918. },
  6919. enumerable: true,
  6920. configurable: true
  6921. });
  6922. Object.defineProperty(InputText.prototype, "thickness", {
  6923. /** Gets or sets border thickness */
  6924. get: function () {
  6925. return this._thickness;
  6926. },
  6927. set: function (value) {
  6928. if (this._thickness === value) {
  6929. return;
  6930. }
  6931. this._thickness = value;
  6932. this._markAsDirty();
  6933. },
  6934. enumerable: true,
  6935. configurable: true
  6936. });
  6937. Object.defineProperty(InputText.prototype, "focusedBackground", {
  6938. /** Gets or sets the background color when focused */
  6939. get: function () {
  6940. return this._focusedBackground;
  6941. },
  6942. set: function (value) {
  6943. if (this._focusedBackground === value) {
  6944. return;
  6945. }
  6946. this._focusedBackground = value;
  6947. this._markAsDirty();
  6948. },
  6949. enumerable: true,
  6950. configurable: true
  6951. });
  6952. Object.defineProperty(InputText.prototype, "focusedColor", {
  6953. /** Gets or sets the background color when focused */
  6954. get: function () {
  6955. return this._focusedColor;
  6956. },
  6957. set: function (value) {
  6958. if (this._focusedColor === value) {
  6959. return;
  6960. }
  6961. this._focusedColor = value;
  6962. this._markAsDirty();
  6963. },
  6964. enumerable: true,
  6965. configurable: true
  6966. });
  6967. Object.defineProperty(InputText.prototype, "background", {
  6968. /** Gets or sets the background color */
  6969. get: function () {
  6970. return this._background;
  6971. },
  6972. set: function (value) {
  6973. if (this._background === value) {
  6974. return;
  6975. }
  6976. this._background = value;
  6977. this._markAsDirty();
  6978. },
  6979. enumerable: true,
  6980. configurable: true
  6981. });
  6982. Object.defineProperty(InputText.prototype, "placeholderColor", {
  6983. /** Gets or sets the placeholder color */
  6984. get: function () {
  6985. return this._placeholderColor;
  6986. },
  6987. set: function (value) {
  6988. if (this._placeholderColor === value) {
  6989. return;
  6990. }
  6991. this._placeholderColor = value;
  6992. this._markAsDirty();
  6993. },
  6994. enumerable: true,
  6995. configurable: true
  6996. });
  6997. Object.defineProperty(InputText.prototype, "placeholderText", {
  6998. /** Gets or sets the text displayed when the control is empty */
  6999. get: function () {
  7000. return this._placeholderText;
  7001. },
  7002. set: function (value) {
  7003. if (this._placeholderText === value) {
  7004. return;
  7005. }
  7006. this._placeholderText = value;
  7007. this._markAsDirty();
  7008. },
  7009. enumerable: true,
  7010. configurable: true
  7011. });
  7012. Object.defineProperty(InputText.prototype, "deadKey", {
  7013. /** Gets or sets the dead key flag */
  7014. get: function () {
  7015. return this._deadKey;
  7016. },
  7017. set: function (flag) {
  7018. this._deadKey = flag;
  7019. },
  7020. enumerable: true,
  7021. configurable: true
  7022. });
  7023. Object.defineProperty(InputText.prototype, "highlightedText", {
  7024. /** Gets or sets the highlight text */
  7025. get: function () {
  7026. return this._highlightedText;
  7027. },
  7028. set: function (text) {
  7029. if (this._highlightedText === text) {
  7030. return;
  7031. }
  7032. this._highlightedText = text;
  7033. this._markAsDirty();
  7034. },
  7035. enumerable: true,
  7036. configurable: true
  7037. });
  7038. Object.defineProperty(InputText.prototype, "addKey", {
  7039. /** Gets or sets if the current key should be added */
  7040. get: function () {
  7041. return this._addKey;
  7042. },
  7043. set: function (flag) {
  7044. this._addKey = flag;
  7045. },
  7046. enumerable: true,
  7047. configurable: true
  7048. });
  7049. Object.defineProperty(InputText.prototype, "currentKey", {
  7050. /** Gets or sets the value of the current key being entered */
  7051. get: function () {
  7052. return this._currentKey;
  7053. },
  7054. set: function (key) {
  7055. this._currentKey = key;
  7056. },
  7057. enumerable: true,
  7058. configurable: true
  7059. });
  7060. Object.defineProperty(InputText.prototype, "text", {
  7061. /** Gets or sets the text displayed in the control */
  7062. get: function () {
  7063. return this._text;
  7064. },
  7065. set: function (value) {
  7066. var valueAsString = value.toString(); // Forcing convertion
  7067. if (this._text === valueAsString) {
  7068. return;
  7069. }
  7070. this._text = valueAsString;
  7071. this._markAsDirty();
  7072. this.onTextChangedObservable.notifyObservers(this);
  7073. },
  7074. enumerable: true,
  7075. configurable: true
  7076. });
  7077. Object.defineProperty(InputText.prototype, "width", {
  7078. /** Gets or sets control width */
  7079. get: function () {
  7080. return this._width.toString(this._host);
  7081. },
  7082. set: function (value) {
  7083. if (this._width.toString(this._host) === value) {
  7084. return;
  7085. }
  7086. if (this._width.fromString(value)) {
  7087. this._markAsDirty();
  7088. }
  7089. this.autoStretchWidth = false;
  7090. },
  7091. enumerable: true,
  7092. configurable: true
  7093. });
  7094. /** @hidden */
  7095. InputText.prototype.onBlur = function () {
  7096. this._isFocused = false;
  7097. this._scrollLeft = null;
  7098. this._cursorOffset = 0;
  7099. clearTimeout(this._blinkTimeout);
  7100. this._markAsDirty();
  7101. this.onBlurObservable.notifyObservers(this);
  7102. this._host.unRegisterClipboardEvents();
  7103. if (this._onClipboardObserver) {
  7104. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7105. }
  7106. var scene = this._host.getScene();
  7107. if (this._onPointerDblTapObserver && scene) {
  7108. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7109. }
  7110. };
  7111. /** @hidden */
  7112. InputText.prototype.onFocus = function () {
  7113. var _this = this;
  7114. if (!this._isEnabled) {
  7115. return;
  7116. }
  7117. this._scrollLeft = null;
  7118. this._isFocused = true;
  7119. this._blinkIsEven = false;
  7120. this._cursorOffset = 0;
  7121. this._markAsDirty();
  7122. this.onFocusObservable.notifyObservers(this);
  7123. if (navigator.userAgent.indexOf("Mobile") !== -1) {
  7124. var value = prompt(this.promptMessage);
  7125. if (value !== null) {
  7126. this.text = value;
  7127. }
  7128. this._host.focusedControl = null;
  7129. return;
  7130. }
  7131. this._host.registerClipboardEvents();
  7132. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7133. // process clipboard event, can be configured.
  7134. switch (clipboardInfo.type) {
  7135. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7136. _this._onCopyText(clipboardInfo.event);
  7137. _this.onTextCopyObservable.notifyObservers(_this);
  7138. break;
  7139. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7140. _this._onCutText(clipboardInfo.event);
  7141. _this.onTextCutObservable.notifyObservers(_this);
  7142. break;
  7143. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7144. _this._onPasteText(clipboardInfo.event);
  7145. _this.onTextPasteObservable.notifyObservers(_this);
  7146. break;
  7147. default: return;
  7148. }
  7149. });
  7150. var scene = this._host.getScene();
  7151. if (scene) {
  7152. //register the pointer double tap event
  7153. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7154. if (!_this._isFocused) {
  7155. return;
  7156. }
  7157. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7158. _this._processDblClick(pointerInfo);
  7159. }
  7160. });
  7161. }
  7162. if (this._onFocusSelectAll) {
  7163. this._selectAllText();
  7164. }
  7165. };
  7166. InputText.prototype._getTypeName = function () {
  7167. return "InputText";
  7168. };
  7169. /**
  7170. * Function called to get the list of controls that should not steal the focus from this control
  7171. * @returns an array of controls
  7172. */
  7173. InputText.prototype.keepsFocusWith = function () {
  7174. if (!this._connectedVirtualKeyboard) {
  7175. return null;
  7176. }
  7177. return [this._connectedVirtualKeyboard];
  7178. };
  7179. /** @hidden */
  7180. InputText.prototype.processKey = function (keyCode, key, evt) {
  7181. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7182. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7183. return;
  7184. }
  7185. //select all
  7186. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7187. this._selectAllText();
  7188. evt.preventDefault();
  7189. return;
  7190. }
  7191. // Specific cases
  7192. switch (keyCode) {
  7193. case 32: //SPACE
  7194. key = " "; //ie11 key for space is "Spacebar"
  7195. break;
  7196. case 191: //SLASH
  7197. if (evt) {
  7198. evt.preventDefault();
  7199. }
  7200. break;
  7201. case 8: // BACKSPACE
  7202. if (this._text && this._text.length > 0) {
  7203. //delete the highlighted text
  7204. if (this._isTextHighlightOn) {
  7205. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7206. this._isTextHighlightOn = false;
  7207. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7208. this._blinkIsEven = false;
  7209. if (evt) {
  7210. evt.preventDefault();
  7211. }
  7212. return;
  7213. }
  7214. //delete single character
  7215. if (this._cursorOffset === 0) {
  7216. this.text = this._text.substr(0, this._text.length - 1);
  7217. }
  7218. else {
  7219. var deletePosition = this._text.length - this._cursorOffset;
  7220. if (deletePosition > 0) {
  7221. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7222. }
  7223. }
  7224. }
  7225. if (evt) {
  7226. evt.preventDefault();
  7227. }
  7228. return;
  7229. case 46: // DELETE
  7230. if (this._isTextHighlightOn) {
  7231. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7232. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7233. while (decrementor > 0 && this._cursorOffset > 0) {
  7234. this._cursorOffset--;
  7235. }
  7236. this._isTextHighlightOn = false;
  7237. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7238. if (evt) {
  7239. evt.preventDefault();
  7240. }
  7241. return;
  7242. }
  7243. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7244. var deletePosition = this._text.length - this._cursorOffset;
  7245. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7246. this._cursorOffset--;
  7247. }
  7248. if (evt) {
  7249. evt.preventDefault();
  7250. }
  7251. return;
  7252. case 13: // RETURN
  7253. this._host.focusedControl = null;
  7254. this._isTextHighlightOn = false;
  7255. return;
  7256. case 35: // END
  7257. this._cursorOffset = 0;
  7258. this._blinkIsEven = false;
  7259. this._isTextHighlightOn = false;
  7260. this._markAsDirty();
  7261. return;
  7262. case 36: // HOME
  7263. this._cursorOffset = this._text.length;
  7264. this._blinkIsEven = false;
  7265. this._isTextHighlightOn = false;
  7266. this._markAsDirty();
  7267. return;
  7268. case 37: // LEFT
  7269. this._cursorOffset++;
  7270. if (this._cursorOffset > this._text.length) {
  7271. this._cursorOffset = this._text.length;
  7272. }
  7273. if (evt && evt.shiftKey) {
  7274. // update the cursor
  7275. this._blinkIsEven = false;
  7276. // shift + ctrl/cmd + <-
  7277. if (evt.ctrlKey || evt.metaKey) {
  7278. if (!this._isTextHighlightOn) {
  7279. if (this._text.length === this._cursorOffset) {
  7280. return;
  7281. }
  7282. else {
  7283. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7284. }
  7285. }
  7286. this._startHighlightIndex = 0;
  7287. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7288. this._cursorOffset = this._text.length;
  7289. this._isTextHighlightOn = true;
  7290. this._markAsDirty();
  7291. return;
  7292. }
  7293. //store the starting point
  7294. if (!this._isTextHighlightOn) {
  7295. this._isTextHighlightOn = true;
  7296. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7297. }
  7298. //if text is already highlighted
  7299. else if (this._cursorIndex === -1) {
  7300. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7301. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7302. }
  7303. //set the highlight indexes
  7304. if (this._cursorIndex < this._cursorOffset) {
  7305. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7306. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7307. }
  7308. else if (this._cursorIndex > this._cursorOffset) {
  7309. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7310. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7311. }
  7312. else {
  7313. this._isTextHighlightOn = false;
  7314. }
  7315. this._markAsDirty();
  7316. return;
  7317. }
  7318. if (this._isTextHighlightOn) {
  7319. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7320. this._isTextHighlightOn = false;
  7321. }
  7322. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7323. this._cursorOffset = this.text.length;
  7324. evt.preventDefault();
  7325. }
  7326. this._blinkIsEven = false;
  7327. this._isTextHighlightOn = false;
  7328. this._cursorIndex = -1;
  7329. this._markAsDirty();
  7330. return;
  7331. case 39: // RIGHT
  7332. this._cursorOffset--;
  7333. if (this._cursorOffset < 0) {
  7334. this._cursorOffset = 0;
  7335. }
  7336. if (evt && evt.shiftKey) {
  7337. //update the cursor
  7338. this._blinkIsEven = false;
  7339. //shift + ctrl/cmd + ->
  7340. if (evt.ctrlKey || evt.metaKey) {
  7341. if (!this._isTextHighlightOn) {
  7342. if (this._cursorOffset === 0) {
  7343. return;
  7344. }
  7345. else {
  7346. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7347. }
  7348. }
  7349. this._endHighlightIndex = this._text.length;
  7350. this._isTextHighlightOn = true;
  7351. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7352. this._cursorOffset = 0;
  7353. this._markAsDirty();
  7354. return;
  7355. }
  7356. if (!this._isTextHighlightOn) {
  7357. this._isTextHighlightOn = true;
  7358. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7359. }
  7360. //if text is already highlighted
  7361. else if (this._cursorIndex === -1) {
  7362. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7363. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7364. }
  7365. //set the highlight indexes
  7366. if (this._cursorIndex < this._cursorOffset) {
  7367. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7368. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7369. }
  7370. else if (this._cursorIndex > this._cursorOffset) {
  7371. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7372. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7373. }
  7374. else {
  7375. this._isTextHighlightOn = false;
  7376. }
  7377. this._markAsDirty();
  7378. return;
  7379. }
  7380. if (this._isTextHighlightOn) {
  7381. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7382. this._isTextHighlightOn = false;
  7383. }
  7384. //ctr + ->
  7385. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7386. this._cursorOffset = 0;
  7387. evt.preventDefault();
  7388. }
  7389. this._blinkIsEven = false;
  7390. this._isTextHighlightOn = false;
  7391. this._cursorIndex = -1;
  7392. this._markAsDirty();
  7393. return;
  7394. case 222: // Dead
  7395. if (evt) {
  7396. evt.preventDefault();
  7397. }
  7398. this._cursorIndex = -1;
  7399. this.deadKey = true;
  7400. break;
  7401. }
  7402. // Printable characters
  7403. if (key &&
  7404. ((keyCode === -1) || // Direct access
  7405. (keyCode === 32) || // Space
  7406. (keyCode > 47 && keyCode < 64) || // Numbers
  7407. (keyCode > 64 && keyCode < 91) || // Letters
  7408. (keyCode > 159 && keyCode < 193) || // Special characters
  7409. (keyCode > 218 && keyCode < 223) || // Special characters
  7410. (keyCode > 95 && keyCode < 112))) { // Numpad
  7411. this._currentKey = key;
  7412. this.onBeforeKeyAddObservable.notifyObservers(this);
  7413. key = this._currentKey;
  7414. if (this._addKey) {
  7415. if (this._isTextHighlightOn) {
  7416. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7417. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7418. this._isTextHighlightOn = false;
  7419. this._blinkIsEven = false;
  7420. this._markAsDirty();
  7421. }
  7422. else if (this._cursorOffset === 0) {
  7423. this.text += key;
  7424. }
  7425. else {
  7426. var insertPosition = this._text.length - this._cursorOffset;
  7427. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7428. }
  7429. }
  7430. }
  7431. };
  7432. /** @hidden */
  7433. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7434. //update the cursor
  7435. this._blinkIsEven = false;
  7436. if (this._cursorIndex === -1) {
  7437. this._cursorIndex = offset;
  7438. }
  7439. else {
  7440. if (this._cursorIndex < this._cursorOffset) {
  7441. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7442. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7443. }
  7444. else if (this._cursorIndex > this._cursorOffset) {
  7445. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7446. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7447. }
  7448. else {
  7449. this._isTextHighlightOn = false;
  7450. this._markAsDirty();
  7451. return;
  7452. }
  7453. }
  7454. this._isTextHighlightOn = true;
  7455. this._markAsDirty();
  7456. };
  7457. /** @hidden */
  7458. InputText.prototype._processDblClick = function (evt) {
  7459. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7460. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7461. this._endHighlightIndex = this._startHighlightIndex;
  7462. var rWord = /\w+/g, moveLeft, moveRight;
  7463. do {
  7464. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7465. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7466. } while (moveLeft || moveRight);
  7467. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7468. this.onTextHighlightObservable.notifyObservers(this);
  7469. this._isTextHighlightOn = true;
  7470. this._clickedCoordinate = null;
  7471. this._blinkIsEven = true;
  7472. this._cursorIndex = -1;
  7473. this._markAsDirty();
  7474. };
  7475. /** @hidden */
  7476. InputText.prototype._selectAllText = function () {
  7477. this._blinkIsEven = true;
  7478. this._isTextHighlightOn = true;
  7479. this._startHighlightIndex = 0;
  7480. this._endHighlightIndex = this._text.length;
  7481. this._cursorOffset = this._text.length;
  7482. this._cursorIndex = -1;
  7483. this._markAsDirty();
  7484. };
  7485. /**
  7486. * Handles the keyboard event
  7487. * @param evt Defines the KeyboardEvent
  7488. */
  7489. InputText.prototype.processKeyboard = function (evt) {
  7490. // process pressed key
  7491. this.processKey(evt.keyCode, evt.key, evt);
  7492. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7493. };
  7494. /** @hidden */
  7495. InputText.prototype._onCopyText = function (ev) {
  7496. this._isTextHighlightOn = false;
  7497. //when write permission to clipbaord data is denied
  7498. try {
  7499. ev.clipboardData.setData("text/plain", this._highlightedText);
  7500. }
  7501. catch (_a) { } //pass
  7502. this._host.clipboardData = this._highlightedText;
  7503. };
  7504. /** @hidden */
  7505. InputText.prototype._onCutText = function (ev) {
  7506. if (!this._highlightedText) {
  7507. return;
  7508. }
  7509. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7510. this._isTextHighlightOn = false;
  7511. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7512. //when write permission to clipbaord data is denied
  7513. try {
  7514. ev.clipboardData.setData("text/plain", this._highlightedText);
  7515. }
  7516. catch (_a) { } //pass
  7517. this._host.clipboardData = this._highlightedText;
  7518. this._highlightedText = "";
  7519. };
  7520. /** @hidden */
  7521. InputText.prototype._onPasteText = function (ev) {
  7522. var data = "";
  7523. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7524. data = ev.clipboardData.getData("text/plain");
  7525. }
  7526. else {
  7527. //get the cached data; returns blank string by default
  7528. data = this._host.clipboardData;
  7529. }
  7530. var insertPosition = this._text.length - this._cursorOffset;
  7531. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7532. };
  7533. InputText.prototype._draw = function (context) {
  7534. var _this = this;
  7535. context.save();
  7536. this._applyStates(context);
  7537. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7538. context.shadowColor = this.shadowColor;
  7539. context.shadowBlur = this.shadowBlur;
  7540. context.shadowOffsetX = this.shadowOffsetX;
  7541. context.shadowOffsetY = this.shadowOffsetY;
  7542. }
  7543. // Background
  7544. if (this._isFocused) {
  7545. if (this._focusedBackground) {
  7546. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7547. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7548. }
  7549. }
  7550. else if (this._background) {
  7551. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7552. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7553. }
  7554. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7555. context.shadowBlur = 0;
  7556. context.shadowOffsetX = 0;
  7557. context.shadowOffsetY = 0;
  7558. }
  7559. if (!this._fontOffset) {
  7560. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7561. }
  7562. // Text
  7563. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7564. if (this.color) {
  7565. context.fillStyle = this.color;
  7566. }
  7567. var text = this._beforeRenderText(this._text);
  7568. if (!this._isFocused && !this._text && this._placeholderText) {
  7569. text = this._placeholderText;
  7570. if (this._placeholderColor) {
  7571. context.fillStyle = this._placeholderColor;
  7572. }
  7573. }
  7574. this._textWidth = context.measureText(text).width;
  7575. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7576. if (this._autoStretchWidth) {
  7577. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7578. }
  7579. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7580. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7581. context.save();
  7582. context.beginPath();
  7583. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7584. context.clip();
  7585. if (this._isFocused && this._textWidth > availableWidth) {
  7586. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7587. if (!this._scrollLeft) {
  7588. this._scrollLeft = textLeft;
  7589. }
  7590. }
  7591. else {
  7592. this._scrollLeft = clipTextLeft;
  7593. }
  7594. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7595. // Cursor
  7596. if (this._isFocused) {
  7597. // Need to move cursor
  7598. if (this._clickedCoordinate) {
  7599. var rightPosition = this._scrollLeft + this._textWidth;
  7600. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7601. var currentSize = 0;
  7602. this._cursorOffset = 0;
  7603. var previousDist = 0;
  7604. do {
  7605. if (this._cursorOffset) {
  7606. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7607. }
  7608. this._cursorOffset++;
  7609. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7610. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7611. // Find closest move
  7612. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7613. this._cursorOffset--;
  7614. }
  7615. this._blinkIsEven = false;
  7616. this._clickedCoordinate = null;
  7617. }
  7618. // Render cursor
  7619. if (!this._blinkIsEven) {
  7620. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7621. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7622. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7623. if (cursorLeft < clipTextLeft) {
  7624. this._scrollLeft += (clipTextLeft - cursorLeft);
  7625. cursorLeft = clipTextLeft;
  7626. this._markAsDirty();
  7627. }
  7628. else if (cursorLeft > clipTextLeft + availableWidth) {
  7629. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7630. cursorLeft = clipTextLeft + availableWidth;
  7631. this._markAsDirty();
  7632. }
  7633. if (!this._isTextHighlightOn) {
  7634. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7635. }
  7636. }
  7637. clearTimeout(this._blinkTimeout);
  7638. this._blinkTimeout = setTimeout(function () {
  7639. _this._blinkIsEven = !_this._blinkIsEven;
  7640. _this._markAsDirty();
  7641. }, 500);
  7642. //show the highlighted text
  7643. if (this._isTextHighlightOn) {
  7644. clearTimeout(this._blinkTimeout);
  7645. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7646. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7647. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7648. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7649. if (highlightCursorLeft < clipTextLeft) {
  7650. width = width - (clipTextLeft - highlightCursorLeft);
  7651. if (!width) {
  7652. // when using left arrow on text.length > availableWidth;
  7653. // assigns the width of the first letter after clipTextLeft
  7654. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7655. }
  7656. highlightCursorLeft = clipTextLeft;
  7657. }
  7658. //for transparancy
  7659. context.globalAlpha = this._highligherOpacity;
  7660. context.fillStyle = this._textHighlightColor;
  7661. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7662. context.globalAlpha = 1.0;
  7663. }
  7664. }
  7665. context.restore();
  7666. // Border
  7667. if (this._thickness) {
  7668. if (this._isFocused) {
  7669. if (this.focusedColor) {
  7670. context.strokeStyle = this.focusedColor;
  7671. }
  7672. }
  7673. else {
  7674. if (this.color) {
  7675. context.strokeStyle = this.color;
  7676. }
  7677. }
  7678. context.lineWidth = this._thickness;
  7679. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7680. }
  7681. context.restore();
  7682. };
  7683. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7684. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7685. return false;
  7686. }
  7687. this._clickedCoordinate = coordinates.x;
  7688. this._isTextHighlightOn = false;
  7689. this._highlightedText = "";
  7690. this._cursorIndex = -1;
  7691. this._isPointerDown = true;
  7692. this._host._capturingControl[pointerId] = this;
  7693. if (this._host.focusedControl === this) {
  7694. // Move cursor
  7695. clearTimeout(this._blinkTimeout);
  7696. this._markAsDirty();
  7697. return true;
  7698. }
  7699. if (!this._isEnabled) {
  7700. return false;
  7701. }
  7702. this._host.focusedControl = this;
  7703. return true;
  7704. };
  7705. InputText.prototype._onPointerMove = function (target, coordinates) {
  7706. if (this._host.focusedControl === this && this._isPointerDown) {
  7707. this._clickedCoordinate = coordinates.x;
  7708. this._markAsDirty();
  7709. this._updateValueFromCursorIndex(this._cursorOffset);
  7710. }
  7711. _super.prototype._onPointerMove.call(this, target, coordinates);
  7712. };
  7713. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7714. this._isPointerDown = false;
  7715. delete this._host._capturingControl[pointerId];
  7716. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7717. };
  7718. InputText.prototype._beforeRenderText = function (text) {
  7719. return text;
  7720. };
  7721. InputText.prototype.dispose = function () {
  7722. _super.prototype.dispose.call(this);
  7723. this.onBlurObservable.clear();
  7724. this.onFocusObservable.clear();
  7725. this.onTextChangedObservable.clear();
  7726. this.onTextCopyObservable.clear();
  7727. this.onTextCutObservable.clear();
  7728. this.onTextPasteObservable.clear();
  7729. this.onTextHighlightObservable.clear();
  7730. this.onKeyboardEventProcessedObservable.clear();
  7731. };
  7732. return InputText;
  7733. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7734. /***/ }),
  7735. /***/ "./2D/controls/line.ts":
  7736. /*!*****************************!*\
  7737. !*** ./2D/controls/line.ts ***!
  7738. \*****************************/
  7739. /*! exports provided: Line */
  7740. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7741. "use strict";
  7742. __webpack_require__.r(__webpack_exports__);
  7743. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7744. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7745. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs");
  7746. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7747. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7748. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7749. /** Class used to render 2D lines */
  7750. var Line = /** @class */ (function (_super) {
  7751. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7752. /**
  7753. * Creates a new Line
  7754. * @param name defines the control name
  7755. */
  7756. function Line(name) {
  7757. var _this = _super.call(this, name) || this;
  7758. _this.name = name;
  7759. _this._lineWidth = 1;
  7760. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7761. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7762. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7763. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7764. _this._dash = new Array();
  7765. _this.isHitTestVisible = false;
  7766. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7767. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7768. return _this;
  7769. }
  7770. Object.defineProperty(Line.prototype, "dash", {
  7771. /** Gets or sets the dash pattern */
  7772. get: function () {
  7773. return this._dash;
  7774. },
  7775. set: function (value) {
  7776. if (this._dash === value) {
  7777. return;
  7778. }
  7779. this._dash = value;
  7780. this._markAsDirty();
  7781. },
  7782. enumerable: true,
  7783. configurable: true
  7784. });
  7785. Object.defineProperty(Line.prototype, "connectedControl", {
  7786. /** Gets or sets the control connected with the line end */
  7787. get: function () {
  7788. return this._connectedControl;
  7789. },
  7790. set: function (value) {
  7791. var _this = this;
  7792. if (this._connectedControl === value) {
  7793. return;
  7794. }
  7795. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7796. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7797. this._connectedControlDirtyObserver = null;
  7798. }
  7799. if (value) {
  7800. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7801. }
  7802. this._connectedControl = value;
  7803. this._markAsDirty();
  7804. },
  7805. enumerable: true,
  7806. configurable: true
  7807. });
  7808. Object.defineProperty(Line.prototype, "x1", {
  7809. /** Gets or sets start coordinates on X axis */
  7810. get: function () {
  7811. return this._x1.toString(this._host);
  7812. },
  7813. set: function (value) {
  7814. if (this._x1.toString(this._host) === value) {
  7815. return;
  7816. }
  7817. if (this._x1.fromString(value)) {
  7818. this._markAsDirty();
  7819. }
  7820. },
  7821. enumerable: true,
  7822. configurable: true
  7823. });
  7824. Object.defineProperty(Line.prototype, "y1", {
  7825. /** Gets or sets start coordinates on Y axis */
  7826. get: function () {
  7827. return this._y1.toString(this._host);
  7828. },
  7829. set: function (value) {
  7830. if (this._y1.toString(this._host) === value) {
  7831. return;
  7832. }
  7833. if (this._y1.fromString(value)) {
  7834. this._markAsDirty();
  7835. }
  7836. },
  7837. enumerable: true,
  7838. configurable: true
  7839. });
  7840. Object.defineProperty(Line.prototype, "x2", {
  7841. /** Gets or sets end coordinates on X axis */
  7842. get: function () {
  7843. return this._x2.toString(this._host);
  7844. },
  7845. set: function (value) {
  7846. if (this._x2.toString(this._host) === value) {
  7847. return;
  7848. }
  7849. if (this._x2.fromString(value)) {
  7850. this._markAsDirty();
  7851. }
  7852. },
  7853. enumerable: true,
  7854. configurable: true
  7855. });
  7856. Object.defineProperty(Line.prototype, "y2", {
  7857. /** Gets or sets end coordinates on Y axis */
  7858. get: function () {
  7859. return this._y2.toString(this._host);
  7860. },
  7861. set: function (value) {
  7862. if (this._y2.toString(this._host) === value) {
  7863. return;
  7864. }
  7865. if (this._y2.fromString(value)) {
  7866. this._markAsDirty();
  7867. }
  7868. },
  7869. enumerable: true,
  7870. configurable: true
  7871. });
  7872. Object.defineProperty(Line.prototype, "lineWidth", {
  7873. /** Gets or sets line width */
  7874. get: function () {
  7875. return this._lineWidth;
  7876. },
  7877. set: function (value) {
  7878. if (this._lineWidth === value) {
  7879. return;
  7880. }
  7881. this._lineWidth = value;
  7882. this._markAsDirty();
  7883. },
  7884. enumerable: true,
  7885. configurable: true
  7886. });
  7887. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7888. /** Gets or sets horizontal alignment */
  7889. set: function (value) {
  7890. return;
  7891. },
  7892. enumerable: true,
  7893. configurable: true
  7894. });
  7895. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7896. /** Gets or sets vertical alignment */
  7897. set: function (value) {
  7898. return;
  7899. },
  7900. enumerable: true,
  7901. configurable: true
  7902. });
  7903. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7904. get: function () {
  7905. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7906. },
  7907. enumerable: true,
  7908. configurable: true
  7909. });
  7910. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7911. get: function () {
  7912. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7913. },
  7914. enumerable: true,
  7915. configurable: true
  7916. });
  7917. Line.prototype._getTypeName = function () {
  7918. return "Line";
  7919. };
  7920. Line.prototype._draw = function (context) {
  7921. context.save();
  7922. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7923. context.shadowColor = this.shadowColor;
  7924. context.shadowBlur = this.shadowBlur;
  7925. context.shadowOffsetX = this.shadowOffsetX;
  7926. context.shadowOffsetY = this.shadowOffsetY;
  7927. }
  7928. this._applyStates(context);
  7929. context.strokeStyle = this.color;
  7930. context.lineWidth = this._lineWidth;
  7931. context.setLineDash(this._dash);
  7932. context.beginPath();
  7933. context.moveTo(this._x1.getValue(this._host), this._y1.getValue(this._host));
  7934. context.lineTo(this._effectiveX2, this._effectiveY2);
  7935. context.stroke();
  7936. context.restore();
  7937. };
  7938. Line.prototype._measure = function () {
  7939. // Width / Height
  7940. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  7941. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  7942. };
  7943. Line.prototype._computeAlignment = function (parentMeasure, context) {
  7944. this._currentMeasure.left = Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  7945. this._currentMeasure.top = Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  7946. };
  7947. /**
  7948. * Move one end of the line given 3D cartesian coordinates.
  7949. * @param position Targeted world position
  7950. * @param scene Scene
  7951. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7952. */
  7953. Line.prototype.moveToVector3 = function (position, scene, end) {
  7954. if (end === void 0) { end = false; }
  7955. if (!this._host || this.parent !== this._host._rootContainer) {
  7956. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  7957. return;
  7958. }
  7959. var globalViewport = this._host._getGlobalViewport(scene);
  7960. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  7961. this._moveToProjectedPosition(projectedPosition, end);
  7962. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  7963. this.notRenderable = true;
  7964. return;
  7965. }
  7966. this.notRenderable = false;
  7967. };
  7968. /**
  7969. * Move one end of the line to a position in screen absolute space.
  7970. * @param projectedPosition Position in screen absolute space (X, Y)
  7971. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7972. */
  7973. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  7974. if (end === void 0) { end = false; }
  7975. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  7976. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  7977. if (end) {
  7978. this.x2 = x;
  7979. this.y2 = y;
  7980. this._x2.ignoreAdaptiveScaling = true;
  7981. this._y2.ignoreAdaptiveScaling = true;
  7982. }
  7983. else {
  7984. this.x1 = x;
  7985. this.y1 = y;
  7986. this._x1.ignoreAdaptiveScaling = true;
  7987. this._y1.ignoreAdaptiveScaling = true;
  7988. }
  7989. };
  7990. return Line;
  7991. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7992. /***/ }),
  7993. /***/ "./2D/controls/multiLine.ts":
  7994. /*!**********************************!*\
  7995. !*** ./2D/controls/multiLine.ts ***!
  7996. \**********************************/
  7997. /*! exports provided: MultiLine */
  7998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7999. "use strict";
  8000. __webpack_require__.r(__webpack_exports__);
  8001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8002. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8003. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs");
  8004. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8005. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8006. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8007. /**
  8008. * Class used to create multi line control
  8009. */
  8010. var MultiLine = /** @class */ (function (_super) {
  8011. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8012. /**
  8013. * Creates a new MultiLine
  8014. * @param name defines the control name
  8015. */
  8016. function MultiLine(name) {
  8017. var _this = _super.call(this, name) || this;
  8018. _this.name = name;
  8019. _this._lineWidth = 1;
  8020. /** Function called when a point is updated */
  8021. _this.onPointUpdate = function () {
  8022. _this._markAsDirty();
  8023. };
  8024. _this.isHitTestVisible = false;
  8025. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8026. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8027. _this._dash = [];
  8028. _this._points = [];
  8029. return _this;
  8030. }
  8031. Object.defineProperty(MultiLine.prototype, "dash", {
  8032. /** Gets or sets dash pattern */
  8033. get: function () {
  8034. return this._dash;
  8035. },
  8036. set: function (value) {
  8037. if (this._dash === value) {
  8038. return;
  8039. }
  8040. this._dash = value;
  8041. this._markAsDirty();
  8042. },
  8043. enumerable: true,
  8044. configurable: true
  8045. });
  8046. /**
  8047. * Gets point stored at specified index
  8048. * @param index defines the index to look for
  8049. * @returns the requested point if found
  8050. */
  8051. MultiLine.prototype.getAt = function (index) {
  8052. if (!this._points[index]) {
  8053. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8054. }
  8055. return this._points[index];
  8056. };
  8057. /**
  8058. * Adds new points to the point collection
  8059. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8060. * @returns the list of created MultiLinePoint
  8061. */
  8062. MultiLine.prototype.add = function () {
  8063. var _this = this;
  8064. var items = [];
  8065. for (var _i = 0; _i < arguments.length; _i++) {
  8066. items[_i] = arguments[_i];
  8067. }
  8068. return items.map(function (item) { return _this.push(item); });
  8069. };
  8070. /**
  8071. * Adds a new point to the point collection
  8072. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8073. * @returns the created MultiLinePoint
  8074. */
  8075. MultiLine.prototype.push = function (item) {
  8076. var point = this.getAt(this._points.length);
  8077. if (item == null) {
  8078. return point;
  8079. }
  8080. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8081. point.mesh = item;
  8082. }
  8083. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8084. point.control = item;
  8085. }
  8086. else if (item.x != null && item.y != null) {
  8087. point.x = item.x;
  8088. point.y = item.y;
  8089. }
  8090. return point;
  8091. };
  8092. /**
  8093. * Remove a specific value or point from the active point collection
  8094. * @param value defines the value or point to remove
  8095. */
  8096. MultiLine.prototype.remove = function (value) {
  8097. var index;
  8098. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8099. index = this._points.indexOf(value);
  8100. if (index === -1) {
  8101. return;
  8102. }
  8103. }
  8104. else {
  8105. index = value;
  8106. }
  8107. var point = this._points[index];
  8108. if (!point) {
  8109. return;
  8110. }
  8111. point.dispose();
  8112. this._points.splice(index, 1);
  8113. };
  8114. /**
  8115. * Resets this object to initial state (no point)
  8116. */
  8117. MultiLine.prototype.reset = function () {
  8118. while (this._points.length > 0) {
  8119. this.remove(this._points.length - 1);
  8120. }
  8121. };
  8122. /**
  8123. * Resets all links
  8124. */
  8125. MultiLine.prototype.resetLinks = function () {
  8126. this._points.forEach(function (point) {
  8127. if (point != null) {
  8128. point.resetLinks();
  8129. }
  8130. });
  8131. };
  8132. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8133. /** Gets or sets line width */
  8134. get: function () {
  8135. return this._lineWidth;
  8136. },
  8137. set: function (value) {
  8138. if (this._lineWidth === value) {
  8139. return;
  8140. }
  8141. this._lineWidth = value;
  8142. this._markAsDirty();
  8143. },
  8144. enumerable: true,
  8145. configurable: true
  8146. });
  8147. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8148. set: function (value) {
  8149. return;
  8150. },
  8151. enumerable: true,
  8152. configurable: true
  8153. });
  8154. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8155. set: function (value) {
  8156. return;
  8157. },
  8158. enumerable: true,
  8159. configurable: true
  8160. });
  8161. MultiLine.prototype._getTypeName = function () {
  8162. return "MultiLine";
  8163. };
  8164. MultiLine.prototype._draw = function (context) {
  8165. context.save();
  8166. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8167. context.shadowColor = this.shadowColor;
  8168. context.shadowBlur = this.shadowBlur;
  8169. context.shadowOffsetX = this.shadowOffsetX;
  8170. context.shadowOffsetY = this.shadowOffsetY;
  8171. }
  8172. this._applyStates(context);
  8173. context.strokeStyle = this.color;
  8174. context.lineWidth = this._lineWidth;
  8175. context.setLineDash(this._dash);
  8176. context.beginPath();
  8177. var first = true; //first index is not necessarily 0
  8178. this._points.forEach(function (point) {
  8179. if (!point) {
  8180. return;
  8181. }
  8182. if (first) {
  8183. context.moveTo(point._point.x, point._point.y);
  8184. first = false;
  8185. }
  8186. else {
  8187. context.lineTo(point._point.x, point._point.y);
  8188. }
  8189. });
  8190. context.stroke();
  8191. context.restore();
  8192. };
  8193. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8194. var _this = this;
  8195. this._minX = null;
  8196. this._minY = null;
  8197. this._maxX = null;
  8198. this._maxY = null;
  8199. this._points.forEach(function (point, index) {
  8200. if (!point) {
  8201. return;
  8202. }
  8203. point.translate();
  8204. if (_this._minX == null || point._point.x < _this._minX) {
  8205. _this._minX = point._point.x;
  8206. }
  8207. if (_this._minY == null || point._point.y < _this._minY) {
  8208. _this._minY = point._point.y;
  8209. }
  8210. if (_this._maxX == null || point._point.x > _this._maxX) {
  8211. _this._maxX = point._point.x;
  8212. }
  8213. if (_this._maxY == null || point._point.y > _this._maxY) {
  8214. _this._maxY = point._point.y;
  8215. }
  8216. });
  8217. if (this._minX == null) {
  8218. this._minX = 0;
  8219. }
  8220. if (this._minY == null) {
  8221. this._minY = 0;
  8222. }
  8223. if (this._maxX == null) {
  8224. this._maxX = 0;
  8225. }
  8226. if (this._maxY == null) {
  8227. this._maxY = 0;
  8228. }
  8229. };
  8230. MultiLine.prototype._measure = function () {
  8231. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8232. return;
  8233. }
  8234. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8235. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8236. };
  8237. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8238. if (this._minX == null || this._minY == null) {
  8239. return;
  8240. }
  8241. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8242. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8243. };
  8244. MultiLine.prototype.dispose = function () {
  8245. this.reset();
  8246. _super.prototype.dispose.call(this);
  8247. };
  8248. return MultiLine;
  8249. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8250. /***/ }),
  8251. /***/ "./2D/controls/radioButton.ts":
  8252. /*!************************************!*\
  8253. !*** ./2D/controls/radioButton.ts ***!
  8254. \************************************/
  8255. /*! exports provided: RadioButton */
  8256. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8257. "use strict";
  8258. __webpack_require__.r(__webpack_exports__);
  8259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8260. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8261. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs");
  8262. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8263. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8264. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8265. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8266. /**
  8267. * Class used to create radio button controls
  8268. */
  8269. var RadioButton = /** @class */ (function (_super) {
  8270. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8271. /**
  8272. * Creates a new RadioButton
  8273. * @param name defines the control name
  8274. */
  8275. function RadioButton(name) {
  8276. var _this = _super.call(this, name) || this;
  8277. _this.name = name;
  8278. _this._isChecked = false;
  8279. _this._background = "black";
  8280. _this._checkSizeRatio = 0.8;
  8281. _this._thickness = 1;
  8282. /** Gets or sets group name */
  8283. _this.group = "";
  8284. /** Observable raised when isChecked is changed */
  8285. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8286. _this.isPointerBlocker = true;
  8287. return _this;
  8288. }
  8289. Object.defineProperty(RadioButton.prototype, "thickness", {
  8290. /** Gets or sets border thickness */
  8291. get: function () {
  8292. return this._thickness;
  8293. },
  8294. set: function (value) {
  8295. if (this._thickness === value) {
  8296. return;
  8297. }
  8298. this._thickness = value;
  8299. this._markAsDirty();
  8300. },
  8301. enumerable: true,
  8302. configurable: true
  8303. });
  8304. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8305. /** Gets or sets a value indicating the ratio between overall size and check size */
  8306. get: function () {
  8307. return this._checkSizeRatio;
  8308. },
  8309. set: function (value) {
  8310. value = Math.max(Math.min(1, value), 0);
  8311. if (this._checkSizeRatio === value) {
  8312. return;
  8313. }
  8314. this._checkSizeRatio = value;
  8315. this._markAsDirty();
  8316. },
  8317. enumerable: true,
  8318. configurable: true
  8319. });
  8320. Object.defineProperty(RadioButton.prototype, "background", {
  8321. /** Gets or sets background color */
  8322. get: function () {
  8323. return this._background;
  8324. },
  8325. set: function (value) {
  8326. if (this._background === value) {
  8327. return;
  8328. }
  8329. this._background = value;
  8330. this._markAsDirty();
  8331. },
  8332. enumerable: true,
  8333. configurable: true
  8334. });
  8335. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8336. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8337. get: function () {
  8338. return this._isChecked;
  8339. },
  8340. set: function (value) {
  8341. var _this = this;
  8342. if (this._isChecked === value) {
  8343. return;
  8344. }
  8345. this._isChecked = value;
  8346. this._markAsDirty();
  8347. this.onIsCheckedChangedObservable.notifyObservers(value);
  8348. if (this._isChecked && this._host) {
  8349. // Update all controls from same group
  8350. this._host.executeOnAllControls(function (control) {
  8351. if (control === _this) {
  8352. return;
  8353. }
  8354. if (control.group === undefined) {
  8355. return;
  8356. }
  8357. var childRadio = control;
  8358. if (childRadio.group === _this.group) {
  8359. childRadio.isChecked = false;
  8360. }
  8361. });
  8362. }
  8363. },
  8364. enumerable: true,
  8365. configurable: true
  8366. });
  8367. RadioButton.prototype._getTypeName = function () {
  8368. return "RadioButton";
  8369. };
  8370. RadioButton.prototype._draw = function (context) {
  8371. context.save();
  8372. this._applyStates(context);
  8373. var actualWidth = this._currentMeasure.width - this._thickness;
  8374. var actualHeight = this._currentMeasure.height - this._thickness;
  8375. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8376. context.shadowColor = this.shadowColor;
  8377. context.shadowBlur = this.shadowBlur;
  8378. context.shadowOffsetX = this.shadowOffsetX;
  8379. context.shadowOffsetY = this.shadowOffsetY;
  8380. }
  8381. // Outer
  8382. _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);
  8383. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8384. context.fill();
  8385. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8386. context.shadowBlur = 0;
  8387. context.shadowOffsetX = 0;
  8388. context.shadowOffsetY = 0;
  8389. }
  8390. context.strokeStyle = this.color;
  8391. context.lineWidth = this._thickness;
  8392. context.stroke();
  8393. // Inner
  8394. if (this._isChecked) {
  8395. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8396. var offsetWidth = actualWidth * this._checkSizeRatio;
  8397. var offseHeight = actualHeight * this._checkSizeRatio;
  8398. _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);
  8399. context.fill();
  8400. }
  8401. context.restore();
  8402. };
  8403. // Events
  8404. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8405. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8406. return false;
  8407. }
  8408. if (!this.isChecked) {
  8409. this.isChecked = true;
  8410. }
  8411. return true;
  8412. };
  8413. /**
  8414. * Utility function to easily create a radio button with a header
  8415. * @param title defines the label to use for the header
  8416. * @param group defines the group to use for the radio button
  8417. * @param isChecked defines the initial state of the radio button
  8418. * @param onValueChanged defines the callback to call when value changes
  8419. * @returns a StackPanel containing the radio button and a textBlock
  8420. */
  8421. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8422. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8423. panel.isVertical = false;
  8424. panel.height = "30px";
  8425. var radio = new RadioButton();
  8426. radio.width = "20px";
  8427. radio.height = "20px";
  8428. radio.isChecked = isChecked;
  8429. radio.color = "green";
  8430. radio.group = group;
  8431. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8432. panel.addControl(radio);
  8433. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8434. header.text = title;
  8435. header.width = "180px";
  8436. header.paddingLeft = "5px";
  8437. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8438. header.color = "white";
  8439. panel.addControl(header);
  8440. return panel;
  8441. };
  8442. return RadioButton;
  8443. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8444. /***/ }),
  8445. /***/ "./2D/controls/rectangle.ts":
  8446. /*!**********************************!*\
  8447. !*** ./2D/controls/rectangle.ts ***!
  8448. \**********************************/
  8449. /*! exports provided: Rectangle */
  8450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8451. "use strict";
  8452. __webpack_require__.r(__webpack_exports__);
  8453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8454. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8455. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8456. /** Class used to create rectangle container */
  8457. var Rectangle = /** @class */ (function (_super) {
  8458. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8459. /**
  8460. * Creates a new Rectangle
  8461. * @param name defines the control name
  8462. */
  8463. function Rectangle(name) {
  8464. var _this = _super.call(this, name) || this;
  8465. _this.name = name;
  8466. _this._thickness = 1;
  8467. _this._cornerRadius = 0;
  8468. return _this;
  8469. }
  8470. Object.defineProperty(Rectangle.prototype, "thickness", {
  8471. /** Gets or sets border thickness */
  8472. get: function () {
  8473. return this._thickness;
  8474. },
  8475. set: function (value) {
  8476. if (this._thickness === value) {
  8477. return;
  8478. }
  8479. this._thickness = value;
  8480. this._markAsDirty();
  8481. },
  8482. enumerable: true,
  8483. configurable: true
  8484. });
  8485. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8486. /** Gets or sets the corner radius angle */
  8487. get: function () {
  8488. return this._cornerRadius;
  8489. },
  8490. set: function (value) {
  8491. if (value < 0) {
  8492. value = 0;
  8493. }
  8494. if (this._cornerRadius === value) {
  8495. return;
  8496. }
  8497. this._cornerRadius = value;
  8498. this._markAsDirty();
  8499. },
  8500. enumerable: true,
  8501. configurable: true
  8502. });
  8503. Rectangle.prototype._getTypeName = function () {
  8504. return "Rectangle";
  8505. };
  8506. Rectangle.prototype._localDraw = function (context) {
  8507. context.save();
  8508. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8509. context.shadowColor = this.shadowColor;
  8510. context.shadowBlur = this.shadowBlur;
  8511. context.shadowOffsetX = this.shadowOffsetX;
  8512. context.shadowOffsetY = this.shadowOffsetY;
  8513. }
  8514. if (this._background) {
  8515. context.fillStyle = this._background;
  8516. if (this._cornerRadius) {
  8517. this._drawRoundedRect(context, this._thickness / 2);
  8518. context.fill();
  8519. }
  8520. else {
  8521. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8522. }
  8523. }
  8524. if (this._thickness) {
  8525. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8526. context.shadowBlur = 0;
  8527. context.shadowOffsetX = 0;
  8528. context.shadowOffsetY = 0;
  8529. }
  8530. if (this.color) {
  8531. context.strokeStyle = this.color;
  8532. }
  8533. context.lineWidth = this._thickness;
  8534. if (this._cornerRadius) {
  8535. this._drawRoundedRect(context, this._thickness / 2);
  8536. context.stroke();
  8537. }
  8538. else {
  8539. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8540. }
  8541. }
  8542. context.restore();
  8543. };
  8544. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8545. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8546. this._measureForChildren.width -= 2 * this._thickness;
  8547. this._measureForChildren.height -= 2 * this._thickness;
  8548. this._measureForChildren.left += this._thickness;
  8549. this._measureForChildren.top += this._thickness;
  8550. };
  8551. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8552. if (offset === void 0) { offset = 0; }
  8553. var x = this._currentMeasure.left + offset;
  8554. var y = this._currentMeasure.top + offset;
  8555. var width = this._currentMeasure.width - offset * 2;
  8556. var height = this._currentMeasure.height - offset * 2;
  8557. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8558. context.beginPath();
  8559. context.moveTo(x + radius, y);
  8560. context.lineTo(x + width - radius, y);
  8561. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8562. context.lineTo(x + width, y + height - radius);
  8563. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8564. context.lineTo(x + radius, y + height);
  8565. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8566. context.lineTo(x, y + radius);
  8567. context.quadraticCurveTo(x, y, x + radius, y);
  8568. context.closePath();
  8569. };
  8570. Rectangle.prototype._clipForChildren = function (context) {
  8571. if (this._cornerRadius) {
  8572. this._drawRoundedRect(context, this._thickness);
  8573. context.clip();
  8574. }
  8575. };
  8576. return Rectangle;
  8577. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8578. /***/ }),
  8579. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8580. /*!***************************************************!*\
  8581. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8582. \***************************************************/
  8583. /*! exports provided: ScrollViewer */
  8584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8585. "use strict";
  8586. __webpack_require__.r(__webpack_exports__);
  8587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8588. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8589. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs");
  8590. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8591. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8592. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8593. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8594. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8595. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8596. /**
  8597. * Class used to hold a viewer window and sliders in a grid
  8598. */
  8599. var ScrollViewer = /** @class */ (function (_super) {
  8600. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8601. /**
  8602. * Creates a new ScrollViewer
  8603. * @param name of ScrollViewer
  8604. */
  8605. function ScrollViewer(name) {
  8606. var _this = _super.call(this, name) || this;
  8607. _this._barSize = 20;
  8608. _this._pointerIsOver = false;
  8609. _this._wheelPrecision = 0.05;
  8610. _this.onDirtyObservable.add(function () {
  8611. _this._horizontalBarSpace.color = _this.color;
  8612. _this._verticalBarSpace.color = _this.color;
  8613. _this._dragSpace.color = _this.color;
  8614. });
  8615. _this.onPointerEnterObservable.add(function () {
  8616. _this._pointerIsOver = true;
  8617. });
  8618. _this.onPointerOutObservable.add(function () {
  8619. _this._pointerIsOver = false;
  8620. });
  8621. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8622. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8623. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8624. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8625. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8626. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8627. _this._grid.addColumnDefinition(1);
  8628. _this._grid.addColumnDefinition(0, true);
  8629. _this._grid.addRowDefinition(1);
  8630. _this._grid.addRowDefinition(0, true);
  8631. _super.prototype.addControl.call(_this, _this._grid);
  8632. _this._grid.addControl(_this._window, 0, 0);
  8633. _this._verticalBar.paddingLeft = 0;
  8634. _this._verticalBar.width = "100%";
  8635. _this._verticalBar.height = "100%";
  8636. _this._verticalBar.barOffset = 0;
  8637. _this._verticalBar.value = 0;
  8638. _this._verticalBar.maximum = 1;
  8639. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8640. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8641. _this._verticalBar.isVertical = true;
  8642. _this._verticalBar.rotation = Math.PI;
  8643. _this._verticalBar.isVisible = false;
  8644. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8645. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8646. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8647. _this._verticalBarSpace.thickness = 1;
  8648. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8649. _this._verticalBarSpace.addControl(_this._verticalBar);
  8650. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8651. _this._window.top = value * _this._endTop + "px";
  8652. });
  8653. _this._horizontalBar.paddingLeft = 0;
  8654. _this._horizontalBar.width = "100%";
  8655. _this._horizontalBar.height = "100%";
  8656. _this._horizontalBar.barOffset = 0;
  8657. _this._horizontalBar.value = 0;
  8658. _this._horizontalBar.maximum = 1;
  8659. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8660. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8661. _this._horizontalBar.isVisible = false;
  8662. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8663. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8664. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8665. _this._horizontalBarSpace.thickness = 1;
  8666. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8667. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8668. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8669. _this._window.left = value * _this._endLeft + "px";
  8670. });
  8671. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8672. _this._dragSpace.thickness = 1;
  8673. _this._grid.addControl(_this._dragSpace, 1, 1);
  8674. // Colors
  8675. _this.barColor = "grey";
  8676. _this.barBackground = "transparent";
  8677. return _this;
  8678. }
  8679. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8680. /**
  8681. * Gets the horizontal scrollbar
  8682. */
  8683. get: function () {
  8684. return this._horizontalBar;
  8685. },
  8686. enumerable: true,
  8687. configurable: true
  8688. });
  8689. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8690. /**
  8691. * Gets the vertical scrollbar
  8692. */
  8693. get: function () {
  8694. return this._verticalBar;
  8695. },
  8696. enumerable: true,
  8697. configurable: true
  8698. });
  8699. /**
  8700. * Adds a new control to the current container
  8701. * @param control defines the control to add
  8702. * @returns the current container
  8703. */
  8704. ScrollViewer.prototype.addControl = function (control) {
  8705. if (!control) {
  8706. return this;
  8707. }
  8708. this._window.addControl(control);
  8709. return this;
  8710. };
  8711. /**
  8712. * Removes a control from the current container
  8713. * @param control defines the control to remove
  8714. * @returns the current container
  8715. */
  8716. ScrollViewer.prototype.removeControl = function (control) {
  8717. this._window.removeControl(control);
  8718. return this;
  8719. };
  8720. Object.defineProperty(ScrollViewer.prototype, "children", {
  8721. /** Gets the list of children */
  8722. get: function () {
  8723. return this._window.children;
  8724. },
  8725. enumerable: true,
  8726. configurable: true
  8727. });
  8728. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8729. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8730. var child = _a[_i];
  8731. child._markMatrixAsDirty();
  8732. }
  8733. };
  8734. /** Reset the scroll viewer window to initial size */
  8735. ScrollViewer.prototype.resetWindow = function () {
  8736. this._window.width = "100%";
  8737. this._window.height = "100%";
  8738. };
  8739. ScrollViewer.prototype._getTypeName = function () {
  8740. return "ScrollViewer";
  8741. };
  8742. ScrollViewer.prototype._buildClientSizes = function () {
  8743. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8744. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8745. this._clientWidth = this._window.parentClientWidth;
  8746. this._clientHeight = this._window.parentClientHeight;
  8747. };
  8748. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8749. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8750. this._buildClientSizes();
  8751. };
  8752. ScrollViewer.prototype._postMeasure = function () {
  8753. _super.prototype._postMeasure.call(this);
  8754. this._updateScroller();
  8755. };
  8756. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8757. /**
  8758. * Gets or sets the mouse wheel precision
  8759. * from 0 to 1 with a default value of 0.05
  8760. * */
  8761. get: function () {
  8762. return this._wheelPrecision;
  8763. },
  8764. set: function (value) {
  8765. if (this._wheelPrecision === value) {
  8766. return;
  8767. }
  8768. if (value < 0) {
  8769. value = 0;
  8770. }
  8771. if (value > 1) {
  8772. value = 1;
  8773. }
  8774. this._wheelPrecision = value;
  8775. },
  8776. enumerable: true,
  8777. configurable: true
  8778. });
  8779. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8780. /** Gets or sets the bar color */
  8781. get: function () {
  8782. return this._barColor;
  8783. },
  8784. set: function (color) {
  8785. if (this._barColor === color) {
  8786. return;
  8787. }
  8788. this._barColor = color;
  8789. this._horizontalBar.color = color;
  8790. this._verticalBar.color = color;
  8791. },
  8792. enumerable: true,
  8793. configurable: true
  8794. });
  8795. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8796. /** Gets or sets the size of the bar */
  8797. get: function () {
  8798. return this._barSize;
  8799. },
  8800. set: function (value) {
  8801. if (this._barSize === value) {
  8802. return;
  8803. }
  8804. this._barSize = value;
  8805. this._markAsDirty();
  8806. if (this._horizontalBar.isVisible) {
  8807. this._grid.setRowDefinition(1, this._barSize, true);
  8808. }
  8809. if (this._verticalBar.isVisible) {
  8810. this._grid.setColumnDefinition(1, this._barSize, true);
  8811. }
  8812. },
  8813. enumerable: true,
  8814. configurable: true
  8815. });
  8816. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8817. /** Gets or sets the bar background */
  8818. get: function () {
  8819. return this._barBackground;
  8820. },
  8821. set: function (color) {
  8822. if (this._barBackground === color) {
  8823. return;
  8824. }
  8825. this._barBackground = color;
  8826. this._horizontalBar.background = color;
  8827. this._verticalBar.background = color;
  8828. this._dragSpace.background = color;
  8829. },
  8830. enumerable: true,
  8831. configurable: true
  8832. });
  8833. /** @hidden */
  8834. ScrollViewer.prototype._updateScroller = function () {
  8835. var windowContentsWidth = this._window._currentMeasure.width;
  8836. var windowContentsHeight = this._window._currentMeasure.height;
  8837. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8838. this._grid.setRowDefinition(1, 0, true);
  8839. this._horizontalBar.isVisible = false;
  8840. this._horizontalBar.value = 0;
  8841. this._rebuildLayout = true;
  8842. }
  8843. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8844. this._grid.setRowDefinition(1, this._barSize, true);
  8845. this._horizontalBar.isVisible = true;
  8846. this._rebuildLayout = true;
  8847. }
  8848. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8849. this._grid.setColumnDefinition(1, 0, true);
  8850. this._verticalBar.isVisible = false;
  8851. this._verticalBar.value = 0;
  8852. this._rebuildLayout = true;
  8853. }
  8854. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8855. this._grid.setColumnDefinition(1, this._barSize, true);
  8856. this._verticalBar.isVisible = true;
  8857. this._rebuildLayout = true;
  8858. }
  8859. this._buildClientSizes();
  8860. this._endLeft = this._clientWidth - windowContentsWidth;
  8861. this._endTop = this._clientHeight - windowContentsHeight;
  8862. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8863. var newTop = this._verticalBar.value * this._endTop + "px";
  8864. if (newLeft !== this._window.left) {
  8865. this._window.left = newLeft;
  8866. this._rebuildLayout = true;
  8867. }
  8868. if (newTop !== this._window.top) {
  8869. this._window.top = newTop;
  8870. this._rebuildLayout = true;
  8871. }
  8872. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8873. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8874. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8875. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8876. };
  8877. ScrollViewer.prototype._link = function (host) {
  8878. _super.prototype._link.call(this, host);
  8879. this._attachWheel();
  8880. };
  8881. /** @hidden */
  8882. ScrollViewer.prototype._attachWheel = function () {
  8883. var _this = this;
  8884. if (this._onPointerObserver) {
  8885. return;
  8886. }
  8887. var scene = this._host.getScene();
  8888. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8889. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8890. return;
  8891. }
  8892. if (_this._verticalBar.isVisible == true) {
  8893. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8894. _this._verticalBar.value -= _this._wheelPrecision;
  8895. }
  8896. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8897. _this._verticalBar.value += _this._wheelPrecision;
  8898. }
  8899. }
  8900. if (_this._horizontalBar.isVisible == true) {
  8901. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8902. _this._horizontalBar.value += _this._wheelPrecision;
  8903. }
  8904. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8905. _this._horizontalBar.value -= _this._wheelPrecision;
  8906. }
  8907. }
  8908. });
  8909. };
  8910. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8911. if (!this.isHighlighted) {
  8912. return;
  8913. }
  8914. _super.prototype._renderHighlightSpecific.call(this, context);
  8915. this._grid._renderHighlightSpecific(context);
  8916. context.restore();
  8917. };
  8918. /** Releases associated resources */
  8919. ScrollViewer.prototype.dispose = function () {
  8920. var scene = this._host.getScene();
  8921. if (scene && this._onPointerObserver) {
  8922. scene.onPointerObservable.remove(this._onPointerObserver);
  8923. this._onPointerObserver = null;
  8924. }
  8925. _super.prototype.dispose.call(this);
  8926. };
  8927. return ScrollViewer;
  8928. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  8929. /***/ }),
  8930. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  8931. /*!*********************************************************!*\
  8932. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  8933. \*********************************************************/
  8934. /*! exports provided: _ScrollViewerWindow */
  8935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8936. "use strict";
  8937. __webpack_require__.r(__webpack_exports__);
  8938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  8939. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8940. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  8941. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  8942. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8943. /**
  8944. * Class used to hold a the container for ScrollViewer
  8945. * @hidden
  8946. */
  8947. var _ScrollViewerWindow = /** @class */ (function (_super) {
  8948. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  8949. /**
  8950. * Creates a new ScrollViewerWindow
  8951. * @param name of ScrollViewerWindow
  8952. */
  8953. function _ScrollViewerWindow(name) {
  8954. return _super.call(this, name) || this;
  8955. }
  8956. _ScrollViewerWindow.prototype._getTypeName = function () {
  8957. return "ScrollViewerWindow";
  8958. };
  8959. /** @hidden */
  8960. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  8961. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8962. this._measureForChildren.left = this._currentMeasure.left;
  8963. this._measureForChildren.top = this._currentMeasure.top;
  8964. this._measureForChildren.width = parentMeasure.width;
  8965. this._measureForChildren.height = parentMeasure.height;
  8966. };
  8967. _ScrollViewerWindow.prototype._postMeasure = function () {
  8968. var maxWidth = this.parentClientWidth;
  8969. var maxHeight = this.parentClientHeight;
  8970. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  8971. var child = _a[_i];
  8972. if (!child.isVisible || child.notRenderable) {
  8973. continue;
  8974. }
  8975. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  8976. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  8977. }
  8978. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  8979. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  8980. }
  8981. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  8982. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  8983. }
  8984. if (this._currentMeasure.width !== maxWidth) {
  8985. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  8986. this._currentMeasure.width = maxWidth;
  8987. this._rebuildLayout = true;
  8988. this._isDirty = true;
  8989. }
  8990. if (this._currentMeasure.height !== maxHeight) {
  8991. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  8992. this._currentMeasure.height = maxHeight;
  8993. this._rebuildLayout = true;
  8994. this._isDirty = true;
  8995. }
  8996. _super.prototype._postMeasure.call(this);
  8997. };
  8998. return _ScrollViewerWindow;
  8999. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9000. /***/ }),
  9001. /***/ "./2D/controls/selector.ts":
  9002. /*!*********************************!*\
  9003. !*** ./2D/controls/selector.ts ***!
  9004. \*********************************/
  9005. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9006. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9007. "use strict";
  9008. __webpack_require__.r(__webpack_exports__);
  9009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9010. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9012. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9014. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9015. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9016. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9017. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9018. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9019. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9020. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9021. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9022. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9023. /** Class used to create a RadioGroup
  9024. * which contains groups of radio buttons
  9025. */
  9026. var SelectorGroup = /** @class */ (function () {
  9027. /**
  9028. * Creates a new SelectorGroup
  9029. * @param name of group, used as a group heading
  9030. */
  9031. function SelectorGroup(
  9032. /** name of SelectorGroup */
  9033. name) {
  9034. this.name = name;
  9035. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9036. this._selectors = new Array();
  9037. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9038. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9039. this._groupHeader = this._addGroupHeader(name);
  9040. }
  9041. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9042. /** Gets the groupPanel of the SelectorGroup */
  9043. get: function () {
  9044. return this._groupPanel;
  9045. },
  9046. enumerable: true,
  9047. configurable: true
  9048. });
  9049. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9050. /** Gets the selectors array */
  9051. get: function () {
  9052. return this._selectors;
  9053. },
  9054. enumerable: true,
  9055. configurable: true
  9056. });
  9057. Object.defineProperty(SelectorGroup.prototype, "header", {
  9058. /** Gets and sets the group header */
  9059. get: function () {
  9060. return this._groupHeader.text;
  9061. },
  9062. set: function (label) {
  9063. if (this._groupHeader.text === "label") {
  9064. return;
  9065. }
  9066. this._groupHeader.text = label;
  9067. },
  9068. enumerable: true,
  9069. configurable: true
  9070. });
  9071. /** @hidden */
  9072. SelectorGroup.prototype._addGroupHeader = function (text) {
  9073. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9074. groupHeading.width = 0.9;
  9075. groupHeading.height = "30px";
  9076. groupHeading.textWrapping = true;
  9077. groupHeading.color = "black";
  9078. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9079. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9080. groupHeading.left = "2px";
  9081. this._groupPanel.addControl(groupHeading);
  9082. return groupHeading;
  9083. };
  9084. /** @hidden*/
  9085. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9086. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9087. return;
  9088. }
  9089. return this._selectors[selectorNb];
  9090. };
  9091. /** Removes the selector at the given position
  9092. * @param selectorNb the position of the selector within the group
  9093. */
  9094. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9095. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9096. return;
  9097. }
  9098. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9099. this._selectors.splice(selectorNb, 1);
  9100. };
  9101. return SelectorGroup;
  9102. }());
  9103. /** Class used to create a CheckboxGroup
  9104. * which contains groups of checkbox buttons
  9105. */
  9106. var CheckboxGroup = /** @class */ (function (_super) {
  9107. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9108. function CheckboxGroup() {
  9109. return _super !== null && _super.apply(this, arguments) || this;
  9110. }
  9111. /** Adds a checkbox as a control
  9112. * @param text is the label for the selector
  9113. * @param func is the function called when the Selector is checked
  9114. * @param checked is true when Selector is checked
  9115. */
  9116. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9117. if (func === void 0) { func = function (s) { }; }
  9118. if (checked === void 0) { checked = false; }
  9119. var checked = checked || false;
  9120. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9121. button.width = "20px";
  9122. button.height = "20px";
  9123. button.color = "#364249";
  9124. button.background = "#CCCCCC";
  9125. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9126. button.onIsCheckedChangedObservable.add(function (state) {
  9127. func(state);
  9128. });
  9129. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9130. _selector.height = "30px";
  9131. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9132. _selector.left = "4px";
  9133. this.groupPanel.addControl(_selector);
  9134. this.selectors.push(_selector);
  9135. button.isChecked = checked;
  9136. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9137. button.color = this.groupPanel.parent.parent.buttonColor;
  9138. button.background = this.groupPanel.parent.parent.buttonBackground;
  9139. }
  9140. };
  9141. /** @hidden */
  9142. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9143. this.selectors[selectorNb].children[1].text = label;
  9144. };
  9145. /** @hidden */
  9146. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9147. this.selectors[selectorNb].children[1].color = color;
  9148. };
  9149. /** @hidden */
  9150. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9151. this.selectors[selectorNb].children[0].color = color;
  9152. };
  9153. /** @hidden */
  9154. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9155. this.selectors[selectorNb].children[0].background = color;
  9156. };
  9157. return CheckboxGroup;
  9158. }(SelectorGroup));
  9159. /** Class used to create a RadioGroup
  9160. * which contains groups of radio buttons
  9161. */
  9162. var RadioGroup = /** @class */ (function (_super) {
  9163. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9164. function RadioGroup() {
  9165. var _this = _super !== null && _super.apply(this, arguments) || this;
  9166. _this._selectNb = 0;
  9167. return _this;
  9168. }
  9169. /** Adds a radio button as a control
  9170. * @param label is the label for the selector
  9171. * @param func is the function called when the Selector is checked
  9172. * @param checked is true when Selector is checked
  9173. */
  9174. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9175. if (func === void 0) { func = function (n) { }; }
  9176. if (checked === void 0) { checked = false; }
  9177. var nb = this._selectNb++;
  9178. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9179. button.name = label;
  9180. button.width = "20px";
  9181. button.height = "20px";
  9182. button.color = "#364249";
  9183. button.background = "#CCCCCC";
  9184. button.group = this.name;
  9185. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9186. button.onIsCheckedChangedObservable.add(function (state) {
  9187. if (state) {
  9188. func(nb);
  9189. }
  9190. });
  9191. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9192. _selector.height = "30px";
  9193. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9194. _selector.left = "4px";
  9195. this.groupPanel.addControl(_selector);
  9196. this.selectors.push(_selector);
  9197. button.isChecked = checked;
  9198. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9199. button.color = this.groupPanel.parent.parent.buttonColor;
  9200. button.background = this.groupPanel.parent.parent.buttonBackground;
  9201. }
  9202. };
  9203. /** @hidden */
  9204. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9205. this.selectors[selectorNb].children[1].text = label;
  9206. };
  9207. /** @hidden */
  9208. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9209. this.selectors[selectorNb].children[1].color = color;
  9210. };
  9211. /** @hidden */
  9212. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9213. this.selectors[selectorNb].children[0].color = color;
  9214. };
  9215. /** @hidden */
  9216. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9217. this.selectors[selectorNb].children[0].background = color;
  9218. };
  9219. return RadioGroup;
  9220. }(SelectorGroup));
  9221. /** Class used to create a SliderGroup
  9222. * which contains groups of slider buttons
  9223. */
  9224. var SliderGroup = /** @class */ (function (_super) {
  9225. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9226. function SliderGroup() {
  9227. return _super !== null && _super.apply(this, arguments) || this;
  9228. }
  9229. /**
  9230. * Adds a slider to the SelectorGroup
  9231. * @param label is the label for the SliderBar
  9232. * @param func is the function called when the Slider moves
  9233. * @param unit is a string describing the units used, eg degrees or metres
  9234. * @param min is the minimum value for the Slider
  9235. * @param max is the maximum value for the Slider
  9236. * @param value is the start value for the Slider between min and max
  9237. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9238. */
  9239. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9240. if (func === void 0) { func = function (v) { }; }
  9241. if (unit === void 0) { unit = "Units"; }
  9242. if (min === void 0) { min = 0; }
  9243. if (max === void 0) { max = 0; }
  9244. if (value === void 0) { value = 0; }
  9245. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9246. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9247. button.name = unit;
  9248. button.value = value;
  9249. button.minimum = min;
  9250. button.maximum = max;
  9251. button.width = 0.9;
  9252. button.height = "20px";
  9253. button.color = "#364249";
  9254. button.background = "#CCCCCC";
  9255. button.borderColor = "black";
  9256. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9257. button.left = "4px";
  9258. button.paddingBottom = "4px";
  9259. button.onValueChangedObservable.add(function (value) {
  9260. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9261. func(value);
  9262. });
  9263. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9264. _selector.height = "60px";
  9265. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9266. _selector.left = "4px";
  9267. _selector.children[0].name = label;
  9268. this.groupPanel.addControl(_selector);
  9269. this.selectors.push(_selector);
  9270. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9271. button.color = this.groupPanel.parent.parent.buttonColor;
  9272. button.background = this.groupPanel.parent.parent.buttonBackground;
  9273. }
  9274. };
  9275. /** @hidden */
  9276. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9277. this.selectors[selectorNb].children[0].name = label;
  9278. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9279. };
  9280. /** @hidden */
  9281. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9282. this.selectors[selectorNb].children[0].color = color;
  9283. };
  9284. /** @hidden */
  9285. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9286. this.selectors[selectorNb].children[1].color = color;
  9287. };
  9288. /** @hidden */
  9289. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9290. this.selectors[selectorNb].children[1].background = color;
  9291. };
  9292. return SliderGroup;
  9293. }(SelectorGroup));
  9294. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9295. * @see http://doc.babylonjs.com/how_to/selector
  9296. */
  9297. var SelectionPanel = /** @class */ (function (_super) {
  9298. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9299. /**
  9300. * Creates a new SelectionPanel
  9301. * @param name of SelectionPanel
  9302. * @param groups is an array of SelectionGroups
  9303. */
  9304. function SelectionPanel(
  9305. /** name of SelectionPanel */
  9306. name,
  9307. /** an array of SelectionGroups */
  9308. groups) {
  9309. if (groups === void 0) { groups = []; }
  9310. var _this = _super.call(this, name) || this;
  9311. _this.name = name;
  9312. _this.groups = groups;
  9313. _this._buttonColor = "#364249";
  9314. _this._buttonBackground = "#CCCCCC";
  9315. _this._headerColor = "black";
  9316. _this._barColor = "white";
  9317. _this._barHeight = "2px";
  9318. _this._spacerHeight = "20px";
  9319. _this._bars = new Array();
  9320. _this._groups = groups;
  9321. _this.thickness = 2;
  9322. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9323. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9324. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9325. _this._panel.top = 5;
  9326. _this._panel.left = 5;
  9327. _this._panel.width = 0.95;
  9328. if (groups.length > 0) {
  9329. for (var i = 0; i < groups.length - 1; i++) {
  9330. _this._panel.addControl(groups[i].groupPanel);
  9331. _this._addSpacer();
  9332. }
  9333. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9334. }
  9335. _this.addControl(_this._panel);
  9336. return _this;
  9337. }
  9338. SelectionPanel.prototype._getTypeName = function () {
  9339. return "SelectionPanel";
  9340. };
  9341. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9342. /** Gets or sets the headerColor */
  9343. get: function () {
  9344. return this._headerColor;
  9345. },
  9346. set: function (color) {
  9347. if (this._headerColor === color) {
  9348. return;
  9349. }
  9350. this._headerColor = color;
  9351. this._setHeaderColor();
  9352. },
  9353. enumerable: true,
  9354. configurable: true
  9355. });
  9356. SelectionPanel.prototype._setHeaderColor = function () {
  9357. for (var i = 0; i < this._groups.length; i++) {
  9358. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9359. }
  9360. };
  9361. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9362. /** Gets or sets the button color */
  9363. get: function () {
  9364. return this._buttonColor;
  9365. },
  9366. set: function (color) {
  9367. if (this._buttonColor === color) {
  9368. return;
  9369. }
  9370. this._buttonColor = color;
  9371. this._setbuttonColor();
  9372. },
  9373. enumerable: true,
  9374. configurable: true
  9375. });
  9376. SelectionPanel.prototype._setbuttonColor = function () {
  9377. for (var i = 0; i < this._groups.length; i++) {
  9378. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9379. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9380. }
  9381. }
  9382. };
  9383. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9384. /** Gets or sets the label color */
  9385. get: function () {
  9386. return this._labelColor;
  9387. },
  9388. set: function (color) {
  9389. if (this._labelColor === color) {
  9390. return;
  9391. }
  9392. this._labelColor = color;
  9393. this._setLabelColor();
  9394. },
  9395. enumerable: true,
  9396. configurable: true
  9397. });
  9398. SelectionPanel.prototype._setLabelColor = function () {
  9399. for (var i = 0; i < this._groups.length; i++) {
  9400. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9401. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9402. }
  9403. }
  9404. };
  9405. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9406. /** Gets or sets the button background */
  9407. get: function () {
  9408. return this._buttonBackground;
  9409. },
  9410. set: function (color) {
  9411. if (this._buttonBackground === color) {
  9412. return;
  9413. }
  9414. this._buttonBackground = color;
  9415. this._setButtonBackground();
  9416. },
  9417. enumerable: true,
  9418. configurable: true
  9419. });
  9420. SelectionPanel.prototype._setButtonBackground = function () {
  9421. for (var i = 0; i < this._groups.length; i++) {
  9422. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9423. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9424. }
  9425. }
  9426. };
  9427. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9428. /** Gets or sets the color of separator bar */
  9429. get: function () {
  9430. return this._barColor;
  9431. },
  9432. set: function (color) {
  9433. if (this._barColor === color) {
  9434. return;
  9435. }
  9436. this._barColor = color;
  9437. this._setBarColor();
  9438. },
  9439. enumerable: true,
  9440. configurable: true
  9441. });
  9442. SelectionPanel.prototype._setBarColor = function () {
  9443. for (var i = 0; i < this._bars.length; i++) {
  9444. this._bars[i].children[0].background = this._barColor;
  9445. }
  9446. };
  9447. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9448. /** Gets or sets the height of separator bar */
  9449. get: function () {
  9450. return this._barHeight;
  9451. },
  9452. set: function (value) {
  9453. if (this._barHeight === value) {
  9454. return;
  9455. }
  9456. this._barHeight = value;
  9457. this._setBarHeight();
  9458. },
  9459. enumerable: true,
  9460. configurable: true
  9461. });
  9462. SelectionPanel.prototype._setBarHeight = function () {
  9463. for (var i = 0; i < this._bars.length; i++) {
  9464. this._bars[i].children[0].height = this._barHeight;
  9465. }
  9466. };
  9467. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9468. /** Gets or sets the height of spacers*/
  9469. get: function () {
  9470. return this._spacerHeight;
  9471. },
  9472. set: function (value) {
  9473. if (this._spacerHeight === value) {
  9474. return;
  9475. }
  9476. this._spacerHeight = value;
  9477. this._setSpacerHeight();
  9478. },
  9479. enumerable: true,
  9480. configurable: true
  9481. });
  9482. SelectionPanel.prototype._setSpacerHeight = function () {
  9483. for (var i = 0; i < this._bars.length; i++) {
  9484. this._bars[i].height = this._spacerHeight;
  9485. }
  9486. };
  9487. /** Adds a bar between groups */
  9488. SelectionPanel.prototype._addSpacer = function () {
  9489. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9490. separator.width = 1;
  9491. separator.height = this._spacerHeight;
  9492. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9493. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9494. bar.width = 1;
  9495. bar.height = this._barHeight;
  9496. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9497. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9498. bar.background = this._barColor;
  9499. bar.color = "transparent";
  9500. separator.addControl(bar);
  9501. this._panel.addControl(separator);
  9502. this._bars.push(separator);
  9503. };
  9504. /** Add a group to the selection panel
  9505. * @param group is the selector group to add
  9506. */
  9507. SelectionPanel.prototype.addGroup = function (group) {
  9508. if (this._groups.length > 0) {
  9509. this._addSpacer();
  9510. }
  9511. this._panel.addControl(group.groupPanel);
  9512. this._groups.push(group);
  9513. group.groupPanel.children[0].color = this._headerColor;
  9514. for (var j = 0; j < group.selectors.length; j++) {
  9515. group._setSelectorButtonColor(j, this._buttonColor);
  9516. group._setSelectorButtonBackground(j, this._buttonBackground);
  9517. }
  9518. };
  9519. /** Remove the group from the given position
  9520. * @param groupNb is the position of the group in the list
  9521. */
  9522. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9523. if (groupNb < 0 || groupNb >= this._groups.length) {
  9524. return;
  9525. }
  9526. var group = this._groups[groupNb];
  9527. this._panel.removeControl(group.groupPanel);
  9528. this._groups.splice(groupNb, 1);
  9529. if (groupNb < this._bars.length) {
  9530. this._panel.removeControl(this._bars[groupNb]);
  9531. this._bars.splice(groupNb, 1);
  9532. }
  9533. };
  9534. /** Change a group header label
  9535. * @param label is the new group header label
  9536. * @param groupNb is the number of the group to relabel
  9537. * */
  9538. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9539. if (groupNb < 0 || groupNb >= this._groups.length) {
  9540. return;
  9541. }
  9542. var group = this._groups[groupNb];
  9543. group.groupPanel.children[0].text = label;
  9544. };
  9545. /** Change selector label to the one given
  9546. * @param label is the new selector label
  9547. * @param groupNb is the number of the groupcontaining the selector
  9548. * @param selectorNb is the number of the selector within a group to relabel
  9549. * */
  9550. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9551. if (groupNb < 0 || groupNb >= this._groups.length) {
  9552. return;
  9553. }
  9554. var group = this._groups[groupNb];
  9555. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9556. return;
  9557. }
  9558. group._setSelectorLabel(selectorNb, label);
  9559. };
  9560. /** For a given group position remove the selector at the given position
  9561. * @param groupNb is the number of the group to remove the selector from
  9562. * @param selectorNb is the number of the selector within the group
  9563. */
  9564. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9565. if (groupNb < 0 || groupNb >= this._groups.length) {
  9566. return;
  9567. }
  9568. var group = this._groups[groupNb];
  9569. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9570. return;
  9571. }
  9572. group.removeSelector(selectorNb);
  9573. };
  9574. /** For a given group position of correct type add a checkbox button
  9575. * @param groupNb is the number of the group to remove the selector from
  9576. * @param label is the label for the selector
  9577. * @param func is the function called when the Selector is checked
  9578. * @param checked is true when Selector is checked
  9579. */
  9580. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9581. if (func === void 0) { func = function () { }; }
  9582. if (checked === void 0) { checked = false; }
  9583. if (groupNb < 0 || groupNb >= this._groups.length) {
  9584. return;
  9585. }
  9586. var group = this._groups[groupNb];
  9587. group.addCheckbox(label, func, checked);
  9588. };
  9589. /** For a given group position of correct type add a radio button
  9590. * @param groupNb is the number of the group to remove the selector from
  9591. * @param label is the label for the selector
  9592. * @param func is the function called when the Selector is checked
  9593. * @param checked is true when Selector is checked
  9594. */
  9595. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9596. if (func === void 0) { func = function () { }; }
  9597. if (checked === void 0) { checked = false; }
  9598. if (groupNb < 0 || groupNb >= this._groups.length) {
  9599. return;
  9600. }
  9601. var group = this._groups[groupNb];
  9602. group.addRadio(label, func, checked);
  9603. };
  9604. /**
  9605. * For a given slider group add a slider
  9606. * @param groupNb is the number of the group to add the slider to
  9607. * @param label is the label for the Slider
  9608. * @param func is the function called when the Slider moves
  9609. * @param unit is a string describing the units used, eg degrees or metres
  9610. * @param min is the minimum value for the Slider
  9611. * @param max is the maximum value for the Slider
  9612. * @param value is the start value for the Slider between min and max
  9613. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9614. */
  9615. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9616. if (func === void 0) { func = function () { }; }
  9617. if (unit === void 0) { unit = "Units"; }
  9618. if (min === void 0) { min = 0; }
  9619. if (max === void 0) { max = 0; }
  9620. if (value === void 0) { value = 0; }
  9621. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9622. if (groupNb < 0 || groupNb >= this._groups.length) {
  9623. return;
  9624. }
  9625. var group = this._groups[groupNb];
  9626. group.addSlider(label, func, unit, min, max, value, onVal);
  9627. };
  9628. return SelectionPanel;
  9629. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9630. /***/ }),
  9631. /***/ "./2D/controls/sliders/baseSlider.ts":
  9632. /*!*******************************************!*\
  9633. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9634. \*******************************************/
  9635. /*! exports provided: BaseSlider */
  9636. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9637. "use strict";
  9638. __webpack_require__.r(__webpack_exports__);
  9639. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9640. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9641. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs");
  9642. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9643. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9644. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9645. /**
  9646. * Class used to create slider controls
  9647. */
  9648. var BaseSlider = /** @class */ (function (_super) {
  9649. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9650. /**
  9651. * Creates a new BaseSlider
  9652. * @param name defines the control name
  9653. */
  9654. function BaseSlider(name) {
  9655. var _this = _super.call(this, name) || this;
  9656. _this.name = name;
  9657. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9658. _this._minimum = 0;
  9659. _this._maximum = 100;
  9660. _this._value = 50;
  9661. _this._isVertical = false;
  9662. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9663. _this._isThumbClamped = false;
  9664. _this._displayThumb = true;
  9665. // Shared rendering info
  9666. _this._effectiveBarOffset = 0;
  9667. /** Observable raised when the sldier value changes */
  9668. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9669. // Events
  9670. _this._pointerIsDown = false;
  9671. _this.isPointerBlocker = true;
  9672. return _this;
  9673. }
  9674. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9675. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9676. get: function () {
  9677. return this._displayThumb;
  9678. },
  9679. set: function (value) {
  9680. if (this._displayThumb === value) {
  9681. return;
  9682. }
  9683. this._displayThumb = value;
  9684. this._markAsDirty();
  9685. },
  9686. enumerable: true,
  9687. configurable: true
  9688. });
  9689. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9690. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9691. get: function () {
  9692. return this._barOffset.toString(this._host);
  9693. },
  9694. set: function (value) {
  9695. if (this._barOffset.toString(this._host) === value) {
  9696. return;
  9697. }
  9698. if (this._barOffset.fromString(value)) {
  9699. this._markAsDirty();
  9700. }
  9701. },
  9702. enumerable: true,
  9703. configurable: true
  9704. });
  9705. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9706. /** Gets main bar offset in pixels*/
  9707. get: function () {
  9708. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9709. },
  9710. enumerable: true,
  9711. configurable: true
  9712. });
  9713. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9714. /** Gets or sets thumb width */
  9715. get: function () {
  9716. return this._thumbWidth.toString(this._host);
  9717. },
  9718. set: function (value) {
  9719. if (this._thumbWidth.toString(this._host) === value) {
  9720. return;
  9721. }
  9722. if (this._thumbWidth.fromString(value)) {
  9723. this._markAsDirty();
  9724. }
  9725. },
  9726. enumerable: true,
  9727. configurable: true
  9728. });
  9729. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9730. /** Gets thumb width in pixels */
  9731. get: function () {
  9732. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9733. },
  9734. enumerable: true,
  9735. configurable: true
  9736. });
  9737. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9738. /** Gets or sets minimum value */
  9739. get: function () {
  9740. return this._minimum;
  9741. },
  9742. set: function (value) {
  9743. if (this._minimum === value) {
  9744. return;
  9745. }
  9746. this._minimum = value;
  9747. this._markAsDirty();
  9748. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9749. },
  9750. enumerable: true,
  9751. configurable: true
  9752. });
  9753. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9754. /** Gets or sets maximum value */
  9755. get: function () {
  9756. return this._maximum;
  9757. },
  9758. set: function (value) {
  9759. if (this._maximum === value) {
  9760. return;
  9761. }
  9762. this._maximum = value;
  9763. this._markAsDirty();
  9764. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9765. },
  9766. enumerable: true,
  9767. configurable: true
  9768. });
  9769. Object.defineProperty(BaseSlider.prototype, "value", {
  9770. /** Gets or sets current value */
  9771. get: function () {
  9772. return this._value;
  9773. },
  9774. set: function (value) {
  9775. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9776. if (this._value === value) {
  9777. return;
  9778. }
  9779. this._value = value;
  9780. this._markAsDirty();
  9781. this.onValueChangedObservable.notifyObservers(this._value);
  9782. },
  9783. enumerable: true,
  9784. configurable: true
  9785. });
  9786. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9787. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9788. get: function () {
  9789. return this._isVertical;
  9790. },
  9791. set: function (value) {
  9792. if (this._isVertical === value) {
  9793. return;
  9794. }
  9795. this._isVertical = value;
  9796. this._markAsDirty();
  9797. },
  9798. enumerable: true,
  9799. configurable: true
  9800. });
  9801. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9802. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9803. get: function () {
  9804. return this._isThumbClamped;
  9805. },
  9806. set: function (value) {
  9807. if (this._isThumbClamped === value) {
  9808. return;
  9809. }
  9810. this._isThumbClamped = value;
  9811. this._markAsDirty();
  9812. },
  9813. enumerable: true,
  9814. configurable: true
  9815. });
  9816. BaseSlider.prototype._getTypeName = function () {
  9817. return "BaseSlider";
  9818. };
  9819. BaseSlider.prototype._getThumbPosition = function () {
  9820. if (this.isVertical) {
  9821. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9822. }
  9823. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9824. };
  9825. BaseSlider.prototype._getThumbThickness = function (type) {
  9826. var thumbThickness = 0;
  9827. switch (type) {
  9828. case "circle":
  9829. if (this._thumbWidth.isPixel) {
  9830. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9831. }
  9832. else {
  9833. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9834. }
  9835. break;
  9836. case "rectangle":
  9837. if (this._thumbWidth.isPixel) {
  9838. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9839. }
  9840. else {
  9841. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9842. }
  9843. }
  9844. return thumbThickness;
  9845. };
  9846. BaseSlider.prototype._prepareRenderingData = function (type) {
  9847. // Main bar
  9848. this._effectiveBarOffset = 0;
  9849. this._renderLeft = this._currentMeasure.left;
  9850. this._renderTop = this._currentMeasure.top;
  9851. this._renderWidth = this._currentMeasure.width;
  9852. this._renderHeight = this._currentMeasure.height;
  9853. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9854. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9855. this._effectiveThumbThickness = this._getThumbThickness(type);
  9856. if (this.displayThumb) {
  9857. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9858. }
  9859. //throw error when height is less than width for vertical slider
  9860. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9861. console.error("Height should be greater than width");
  9862. return;
  9863. }
  9864. if (this._barOffset.isPixel) {
  9865. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9866. }
  9867. else {
  9868. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9869. }
  9870. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9871. if (this.isVertical) {
  9872. this._renderLeft += this._effectiveBarOffset;
  9873. if (!this.isThumbClamped && this.displayThumb) {
  9874. this._renderTop += (this._effectiveThumbThickness / 2);
  9875. }
  9876. this._renderHeight = this._backgroundBoxLength;
  9877. this._renderWidth = this._backgroundBoxThickness;
  9878. }
  9879. else {
  9880. this._renderTop += this._effectiveBarOffset;
  9881. if (!this.isThumbClamped && this.displayThumb) {
  9882. this._renderLeft += (this._effectiveThumbThickness / 2);
  9883. }
  9884. this._renderHeight = this._backgroundBoxThickness;
  9885. this._renderWidth = this._backgroundBoxLength;
  9886. }
  9887. };
  9888. /** @hidden */
  9889. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9890. if (this.rotation != 0) {
  9891. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9892. x = this._transformedPosition.x;
  9893. y = this._transformedPosition.y;
  9894. }
  9895. if (this._isVertical) {
  9896. this.value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9897. }
  9898. else {
  9899. this.value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9900. }
  9901. };
  9902. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  9903. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  9904. return false;
  9905. }
  9906. this._pointerIsDown = true;
  9907. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9908. this._host._capturingControl[pointerId] = this;
  9909. return true;
  9910. };
  9911. BaseSlider.prototype._onPointerMove = function (target, coordinates) {
  9912. if (this._pointerIsDown) {
  9913. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9914. }
  9915. _super.prototype._onPointerMove.call(this, target, coordinates);
  9916. };
  9917. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  9918. this._pointerIsDown = false;
  9919. delete this._host._capturingControl[pointerId];
  9920. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  9921. };
  9922. return BaseSlider;
  9923. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9924. /***/ }),
  9925. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  9926. /*!*************************************************!*\
  9927. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  9928. \*************************************************/
  9929. /*! exports provided: ImageBasedSlider */
  9930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9931. "use strict";
  9932. __webpack_require__.r(__webpack_exports__);
  9933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  9934. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9935. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  9936. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9937. /**
  9938. * Class used to create slider controls based on images
  9939. */
  9940. var ImageBasedSlider = /** @class */ (function (_super) {
  9941. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  9942. /**
  9943. * Creates a new ImageBasedSlider
  9944. * @param name defines the control name
  9945. */
  9946. function ImageBasedSlider(name) {
  9947. var _this = _super.call(this, name) || this;
  9948. _this.name = name;
  9949. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  9950. return _this;
  9951. }
  9952. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  9953. get: function () {
  9954. return this._displayThumb && this.thumbImage != null;
  9955. },
  9956. set: function (value) {
  9957. if (this._displayThumb === value) {
  9958. return;
  9959. }
  9960. this._displayThumb = value;
  9961. this._markAsDirty();
  9962. },
  9963. enumerable: true,
  9964. configurable: true
  9965. });
  9966. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  9967. /**
  9968. * Gets or sets the image used to render the background
  9969. */
  9970. get: function () {
  9971. return this._backgroundImage;
  9972. },
  9973. set: function (value) {
  9974. var _this = this;
  9975. if (this._backgroundImage === value) {
  9976. return;
  9977. }
  9978. this._backgroundImage = value;
  9979. if (value && !value.isLoaded) {
  9980. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  9981. }
  9982. this._markAsDirty();
  9983. },
  9984. enumerable: true,
  9985. configurable: true
  9986. });
  9987. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  9988. /**
  9989. * Gets or sets the image used to render the value bar
  9990. */
  9991. get: function () {
  9992. return this._valueBarImage;
  9993. },
  9994. set: function (value) {
  9995. var _this = this;
  9996. if (this._valueBarImage === value) {
  9997. return;
  9998. }
  9999. this._valueBarImage = value;
  10000. if (value && !value.isLoaded) {
  10001. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10002. }
  10003. this._markAsDirty();
  10004. },
  10005. enumerable: true,
  10006. configurable: true
  10007. });
  10008. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10009. /**
  10010. * Gets or sets the image used to render the thumb
  10011. */
  10012. get: function () {
  10013. return this._thumbImage;
  10014. },
  10015. set: function (value) {
  10016. var _this = this;
  10017. if (this._thumbImage === value) {
  10018. return;
  10019. }
  10020. this._thumbImage = value;
  10021. if (value && !value.isLoaded) {
  10022. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10023. }
  10024. this._markAsDirty();
  10025. },
  10026. enumerable: true,
  10027. configurable: true
  10028. });
  10029. ImageBasedSlider.prototype._getTypeName = function () {
  10030. return "ImageBasedSlider";
  10031. };
  10032. ImageBasedSlider.prototype._draw = function (context) {
  10033. context.save();
  10034. this._applyStates(context);
  10035. this._prepareRenderingData("rectangle");
  10036. var thumbPosition = this._getThumbPosition();
  10037. var left = this._renderLeft;
  10038. var top = this._renderTop;
  10039. var width = this._renderWidth;
  10040. var height = this._renderHeight;
  10041. // Background
  10042. if (this._backgroundImage) {
  10043. this._tempMeasure.copyFromFloats(left, top, width, height);
  10044. if (this.isThumbClamped && this.displayThumb) {
  10045. if (this.isVertical) {
  10046. this._tempMeasure.height += this._effectiveThumbThickness;
  10047. }
  10048. else {
  10049. this._tempMeasure.width += this._effectiveThumbThickness;
  10050. }
  10051. }
  10052. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10053. this._backgroundImage._draw(context);
  10054. }
  10055. // Bar
  10056. if (this._valueBarImage) {
  10057. if (this.isVertical) {
  10058. if (this.isThumbClamped && this.displayThumb) {
  10059. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10060. }
  10061. else {
  10062. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10063. }
  10064. }
  10065. else {
  10066. if (this.isThumbClamped && this.displayThumb) {
  10067. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10068. }
  10069. else {
  10070. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10071. }
  10072. }
  10073. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10074. this._valueBarImage._draw(context);
  10075. }
  10076. // Thumb
  10077. if (this.displayThumb) {
  10078. if (this.isVertical) {
  10079. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10080. }
  10081. else {
  10082. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10083. }
  10084. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10085. this._thumbImage._draw(context);
  10086. }
  10087. context.restore();
  10088. };
  10089. return ImageBasedSlider;
  10090. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10091. /***/ }),
  10092. /***/ "./2D/controls/sliders/scrollBar.ts":
  10093. /*!******************************************!*\
  10094. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10095. \******************************************/
  10096. /*! exports provided: ScrollBar */
  10097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10098. "use strict";
  10099. __webpack_require__.r(__webpack_exports__);
  10100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10101. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10102. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10103. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10104. /**
  10105. * Class used to create slider controls
  10106. */
  10107. var ScrollBar = /** @class */ (function (_super) {
  10108. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10109. /**
  10110. * Creates a new Slider
  10111. * @param name defines the control name
  10112. */
  10113. function ScrollBar(name) {
  10114. var _this = _super.call(this, name) || this;
  10115. _this.name = name;
  10116. _this._background = "black";
  10117. _this._borderColor = "white";
  10118. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10119. return _this;
  10120. }
  10121. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10122. /** Gets or sets border color */
  10123. get: function () {
  10124. return this._borderColor;
  10125. },
  10126. set: function (value) {
  10127. if (this._borderColor === value) {
  10128. return;
  10129. }
  10130. this._borderColor = value;
  10131. this._markAsDirty();
  10132. },
  10133. enumerable: true,
  10134. configurable: true
  10135. });
  10136. Object.defineProperty(ScrollBar.prototype, "background", {
  10137. /** Gets or sets background color */
  10138. get: function () {
  10139. return this._background;
  10140. },
  10141. set: function (value) {
  10142. if (this._background === value) {
  10143. return;
  10144. }
  10145. this._background = value;
  10146. this._markAsDirty();
  10147. },
  10148. enumerable: true,
  10149. configurable: true
  10150. });
  10151. ScrollBar.prototype._getTypeName = function () {
  10152. return "Scrollbar";
  10153. };
  10154. ScrollBar.prototype._getThumbThickness = function () {
  10155. var thumbThickness = 0;
  10156. if (this._thumbWidth.isPixel) {
  10157. thumbThickness = this._thumbWidth.getValue(this._host);
  10158. }
  10159. else {
  10160. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10161. }
  10162. return thumbThickness;
  10163. };
  10164. ScrollBar.prototype._draw = function (context) {
  10165. context.save();
  10166. this._applyStates(context);
  10167. this._prepareRenderingData("rectangle");
  10168. var left = this._renderLeft;
  10169. var thumbPosition = this._getThumbPosition();
  10170. context.fillStyle = this._background;
  10171. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10172. // Value bar
  10173. context.fillStyle = this.color;
  10174. // Thumb
  10175. if (this.isVertical) {
  10176. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10177. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10178. this._thumbMeasure.width = this._currentMeasure.width;
  10179. this._thumbMeasure.height = this._effectiveThumbThickness;
  10180. }
  10181. else {
  10182. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10183. this._thumbMeasure.top = this._currentMeasure.top;
  10184. this._thumbMeasure.width = this._effectiveThumbThickness;
  10185. this._thumbMeasure.height = this._currentMeasure.height;
  10186. }
  10187. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10188. context.restore();
  10189. };
  10190. /** @hidden */
  10191. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10192. if (this.rotation != 0) {
  10193. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10194. x = this._transformedPosition.x;
  10195. y = this._transformedPosition.y;
  10196. }
  10197. if (this._first) {
  10198. this._first = false;
  10199. this._originX = x;
  10200. this._originY = y;
  10201. // Check if move is required
  10202. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10203. if (this.isVertical) {
  10204. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10205. }
  10206. else {
  10207. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10208. }
  10209. }
  10210. }
  10211. // Delta mode
  10212. var delta = 0;
  10213. if (this.isVertical) {
  10214. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10215. }
  10216. else {
  10217. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10218. }
  10219. this.value += delta * (this.maximum - this.minimum);
  10220. this._originX = x;
  10221. this._originY = y;
  10222. };
  10223. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10224. this._first = true;
  10225. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10226. };
  10227. return ScrollBar;
  10228. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10229. /***/ }),
  10230. /***/ "./2D/controls/sliders/slider.ts":
  10231. /*!***************************************!*\
  10232. !*** ./2D/controls/sliders/slider.ts ***!
  10233. \***************************************/
  10234. /*! exports provided: Slider */
  10235. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10236. "use strict";
  10237. __webpack_require__.r(__webpack_exports__);
  10238. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10239. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10240. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10241. /**
  10242. * Class used to create slider controls
  10243. */
  10244. var Slider = /** @class */ (function (_super) {
  10245. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10246. /**
  10247. * Creates a new Slider
  10248. * @param name defines the control name
  10249. */
  10250. function Slider(name) {
  10251. var _this = _super.call(this, name) || this;
  10252. _this.name = name;
  10253. _this._background = "black";
  10254. _this._borderColor = "white";
  10255. _this._isThumbCircle = false;
  10256. _this._displayValueBar = true;
  10257. return _this;
  10258. }
  10259. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10260. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10261. get: function () {
  10262. return this._displayValueBar;
  10263. },
  10264. set: function (value) {
  10265. if (this._displayValueBar === value) {
  10266. return;
  10267. }
  10268. this._displayValueBar = value;
  10269. this._markAsDirty();
  10270. },
  10271. enumerable: true,
  10272. configurable: true
  10273. });
  10274. Object.defineProperty(Slider.prototype, "borderColor", {
  10275. /** Gets or sets border color */
  10276. get: function () {
  10277. return this._borderColor;
  10278. },
  10279. set: function (value) {
  10280. if (this._borderColor === value) {
  10281. return;
  10282. }
  10283. this._borderColor = value;
  10284. this._markAsDirty();
  10285. },
  10286. enumerable: true,
  10287. configurable: true
  10288. });
  10289. Object.defineProperty(Slider.prototype, "background", {
  10290. /** Gets or sets background color */
  10291. get: function () {
  10292. return this._background;
  10293. },
  10294. set: function (value) {
  10295. if (this._background === value) {
  10296. return;
  10297. }
  10298. this._background = value;
  10299. this._markAsDirty();
  10300. },
  10301. enumerable: true,
  10302. configurable: true
  10303. });
  10304. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10305. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10306. get: function () {
  10307. return this._isThumbCircle;
  10308. },
  10309. set: function (value) {
  10310. if (this._isThumbCircle === value) {
  10311. return;
  10312. }
  10313. this._isThumbCircle = value;
  10314. this._markAsDirty();
  10315. },
  10316. enumerable: true,
  10317. configurable: true
  10318. });
  10319. Slider.prototype._getTypeName = function () {
  10320. return "Slider";
  10321. };
  10322. Slider.prototype._draw = function (context) {
  10323. context.save();
  10324. this._applyStates(context);
  10325. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10326. var left = this._renderLeft;
  10327. var top = this._renderTop;
  10328. var width = this._renderWidth;
  10329. var height = this._renderHeight;
  10330. var radius = 0;
  10331. if (this.isThumbClamped && this.isThumbCircle) {
  10332. if (this.isVertical) {
  10333. top += (this._effectiveThumbThickness / 2);
  10334. }
  10335. else {
  10336. left += (this._effectiveThumbThickness / 2);
  10337. }
  10338. radius = this._backgroundBoxThickness / 2;
  10339. }
  10340. else {
  10341. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10342. }
  10343. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10344. context.shadowColor = this.shadowColor;
  10345. context.shadowBlur = this.shadowBlur;
  10346. context.shadowOffsetX = this.shadowOffsetX;
  10347. context.shadowOffsetY = this.shadowOffsetY;
  10348. }
  10349. var thumbPosition = this._getThumbPosition();
  10350. context.fillStyle = this._background;
  10351. if (this.isVertical) {
  10352. if (this.isThumbClamped) {
  10353. if (this.isThumbCircle) {
  10354. context.beginPath();
  10355. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10356. context.fill();
  10357. context.fillRect(left, top, width, height);
  10358. }
  10359. else {
  10360. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10361. }
  10362. }
  10363. else {
  10364. context.fillRect(left, top, width, height);
  10365. }
  10366. }
  10367. else {
  10368. if (this.isThumbClamped) {
  10369. if (this.isThumbCircle) {
  10370. context.beginPath();
  10371. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10372. context.fill();
  10373. context.fillRect(left, top, width, height);
  10374. }
  10375. else {
  10376. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10377. }
  10378. }
  10379. else {
  10380. context.fillRect(left, top, width, height);
  10381. }
  10382. }
  10383. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10384. context.shadowBlur = 0;
  10385. context.shadowOffsetX = 0;
  10386. context.shadowOffsetY = 0;
  10387. }
  10388. // Value bar
  10389. context.fillStyle = this.color;
  10390. if (this._displayValueBar) {
  10391. if (this.isVertical) {
  10392. if (this.isThumbClamped) {
  10393. if (this.isThumbCircle) {
  10394. context.beginPath();
  10395. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10396. context.fill();
  10397. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10398. }
  10399. else {
  10400. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10401. }
  10402. }
  10403. else {
  10404. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10405. }
  10406. }
  10407. else {
  10408. if (this.isThumbClamped) {
  10409. if (this.isThumbCircle) {
  10410. context.beginPath();
  10411. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10412. context.fill();
  10413. context.fillRect(left, top, thumbPosition, height);
  10414. }
  10415. else {
  10416. context.fillRect(left, top, thumbPosition, height);
  10417. }
  10418. }
  10419. else {
  10420. context.fillRect(left, top, thumbPosition, height);
  10421. }
  10422. }
  10423. }
  10424. // Thumb
  10425. if (this.displayThumb) {
  10426. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10427. context.shadowColor = this.shadowColor;
  10428. context.shadowBlur = this.shadowBlur;
  10429. context.shadowOffsetX = this.shadowOffsetX;
  10430. context.shadowOffsetY = this.shadowOffsetY;
  10431. }
  10432. if (this._isThumbCircle) {
  10433. context.beginPath();
  10434. if (this.isVertical) {
  10435. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10436. }
  10437. else {
  10438. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10439. }
  10440. context.fill();
  10441. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10442. context.shadowBlur = 0;
  10443. context.shadowOffsetX = 0;
  10444. context.shadowOffsetY = 0;
  10445. }
  10446. context.strokeStyle = this._borderColor;
  10447. context.stroke();
  10448. }
  10449. else {
  10450. if (this.isVertical) {
  10451. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10452. }
  10453. else {
  10454. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10455. }
  10456. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10457. context.shadowBlur = 0;
  10458. context.shadowOffsetX = 0;
  10459. context.shadowOffsetY = 0;
  10460. }
  10461. context.strokeStyle = this._borderColor;
  10462. if (this.isVertical) {
  10463. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10464. }
  10465. else {
  10466. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10467. }
  10468. }
  10469. }
  10470. context.restore();
  10471. };
  10472. return Slider;
  10473. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10474. /***/ }),
  10475. /***/ "./2D/controls/stackPanel.ts":
  10476. /*!***********************************!*\
  10477. !*** ./2D/controls/stackPanel.ts ***!
  10478. \***********************************/
  10479. /*! exports provided: StackPanel */
  10480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10481. "use strict";
  10482. __webpack_require__.r(__webpack_exports__);
  10483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10484. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10485. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs");
  10486. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10487. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10488. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10489. /**
  10490. * Class used to create a 2D stack panel container
  10491. */
  10492. var StackPanel = /** @class */ (function (_super) {
  10493. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10494. /**
  10495. * Creates a new StackPanel
  10496. * @param name defines control name
  10497. */
  10498. function StackPanel(name) {
  10499. var _this = _super.call(this, name) || this;
  10500. _this.name = name;
  10501. _this._isVertical = true;
  10502. _this._manualWidth = false;
  10503. _this._manualHeight = false;
  10504. _this._doNotTrackManualChanges = false;
  10505. return _this;
  10506. }
  10507. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10508. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10509. get: function () {
  10510. return this._isVertical;
  10511. },
  10512. set: function (value) {
  10513. if (this._isVertical === value) {
  10514. return;
  10515. }
  10516. this._isVertical = value;
  10517. this._markAsDirty();
  10518. },
  10519. enumerable: true,
  10520. configurable: true
  10521. });
  10522. Object.defineProperty(StackPanel.prototype, "width", {
  10523. get: function () {
  10524. return this._width.toString(this._host);
  10525. },
  10526. /**
  10527. * Gets or sets panel width.
  10528. * This value should not be set when in horizontal mode as it will be computed automatically
  10529. */
  10530. set: function (value) {
  10531. if (!this._doNotTrackManualChanges) {
  10532. this._manualWidth = true;
  10533. }
  10534. if (this._width.toString(this._host) === value) {
  10535. return;
  10536. }
  10537. if (this._width.fromString(value)) {
  10538. this._markAsDirty();
  10539. }
  10540. },
  10541. enumerable: true,
  10542. configurable: true
  10543. });
  10544. Object.defineProperty(StackPanel.prototype, "height", {
  10545. get: function () {
  10546. return this._height.toString(this._host);
  10547. },
  10548. /**
  10549. * Gets or sets panel height.
  10550. * This value should not be set when in vertical mode as it will be computed automatically
  10551. */
  10552. set: function (value) {
  10553. if (!this._doNotTrackManualChanges) {
  10554. this._manualHeight = true;
  10555. }
  10556. if (this._height.toString(this._host) === value) {
  10557. return;
  10558. }
  10559. if (this._height.fromString(value)) {
  10560. this._markAsDirty();
  10561. }
  10562. },
  10563. enumerable: true,
  10564. configurable: true
  10565. });
  10566. StackPanel.prototype._getTypeName = function () {
  10567. return "StackPanel";
  10568. };
  10569. /** @hidden */
  10570. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10571. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10572. var child = _a[_i];
  10573. if (this._isVertical) {
  10574. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10575. }
  10576. else {
  10577. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10578. }
  10579. }
  10580. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10581. };
  10582. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10583. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10584. this._measureForChildren.copyFrom(parentMeasure);
  10585. this._measureForChildren.left = this._currentMeasure.left;
  10586. this._measureForChildren.top = this._currentMeasure.top;
  10587. if (!this.isVertical || this._manualWidth) {
  10588. this._measureForChildren.width = this._currentMeasure.width;
  10589. }
  10590. if (this.isVertical || this._manualHeight) {
  10591. this._measureForChildren.height = this._currentMeasure.height;
  10592. }
  10593. };
  10594. StackPanel.prototype._postMeasure = function () {
  10595. var stackWidth = 0;
  10596. var stackHeight = 0;
  10597. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10598. var child = _a[_i];
  10599. if (!child.isVisible || child.notRenderable) {
  10600. continue;
  10601. }
  10602. if (this._isVertical) {
  10603. if (child.top !== stackHeight + "px") {
  10604. child.top = stackHeight + "px";
  10605. this._rebuildLayout = true;
  10606. child._top.ignoreAdaptiveScaling = true;
  10607. }
  10608. if (child._height.isPercentage) {
  10609. 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");
  10610. }
  10611. else {
  10612. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10613. }
  10614. }
  10615. else {
  10616. if (child.left !== stackWidth + "px") {
  10617. child.left = stackWidth + "px";
  10618. this._rebuildLayout = true;
  10619. child._left.ignoreAdaptiveScaling = true;
  10620. }
  10621. if (child._width.isPercentage) {
  10622. 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");
  10623. }
  10624. else {
  10625. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10626. }
  10627. }
  10628. }
  10629. this._doNotTrackManualChanges = true;
  10630. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10631. // User can now define their own height and width for stack panel.
  10632. var panelWidthChanged = false;
  10633. var panelHeightChanged = false;
  10634. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10635. var previousHeight = this.height;
  10636. this.height = stackHeight + "px";
  10637. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10638. }
  10639. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10640. var previousWidth = this.width;
  10641. this.width = stackWidth + "px";
  10642. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10643. }
  10644. if (panelHeightChanged) {
  10645. this._height.ignoreAdaptiveScaling = true;
  10646. }
  10647. if (panelWidthChanged) {
  10648. this._width.ignoreAdaptiveScaling = true;
  10649. }
  10650. this._doNotTrackManualChanges = false;
  10651. if (panelWidthChanged || panelHeightChanged) {
  10652. this._rebuildLayout = true;
  10653. }
  10654. _super.prototype._postMeasure.call(this);
  10655. };
  10656. return StackPanel;
  10657. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10658. /***/ }),
  10659. /***/ "./2D/controls/statics.ts":
  10660. /*!********************************!*\
  10661. !*** ./2D/controls/statics.ts ***!
  10662. \********************************/
  10663. /*! exports provided: name */
  10664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10665. "use strict";
  10666. __webpack_require__.r(__webpack_exports__);
  10667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10668. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10669. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10670. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10671. /**
  10672. * Forcing an export so that this code will execute
  10673. * @hidden
  10674. */
  10675. var name = "Statics";
  10676. /**
  10677. * Creates a stack panel that can be used to render headers
  10678. * @param control defines the control to associate with the header
  10679. * @param text defines the text of the header
  10680. * @param size defines the size of the header
  10681. * @param options defines options used to configure the header
  10682. * @returns a new StackPanel
  10683. */
  10684. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10685. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10686. var isHorizontal = options ? options.isHorizontal : true;
  10687. var controlFirst = options ? options.controlFirst : true;
  10688. panel.isVertical = !isHorizontal;
  10689. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10690. header.text = text;
  10691. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10692. if (isHorizontal) {
  10693. header.width = size;
  10694. }
  10695. else {
  10696. header.height = size;
  10697. }
  10698. if (controlFirst) {
  10699. panel.addControl(control);
  10700. panel.addControl(header);
  10701. header.paddingLeft = "5px";
  10702. }
  10703. else {
  10704. panel.addControl(header);
  10705. panel.addControl(control);
  10706. header.paddingRight = "5px";
  10707. }
  10708. header.shadowBlur = control.shadowBlur;
  10709. header.shadowColor = control.shadowColor;
  10710. header.shadowOffsetX = control.shadowOffsetX;
  10711. header.shadowOffsetY = control.shadowOffsetY;
  10712. return panel;
  10713. };
  10714. /***/ }),
  10715. /***/ "./2D/controls/textBlock.ts":
  10716. /*!**********************************!*\
  10717. !*** ./2D/controls/textBlock.ts ***!
  10718. \**********************************/
  10719. /*! exports provided: TextWrapping, TextBlock */
  10720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10721. "use strict";
  10722. __webpack_require__.r(__webpack_exports__);
  10723. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10725. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10726. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs");
  10727. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10728. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10729. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10730. /**
  10731. * Enum that determines the text-wrapping mode to use.
  10732. */
  10733. var TextWrapping;
  10734. (function (TextWrapping) {
  10735. /**
  10736. * Clip the text when it's larger than Control.width; this is the default mode.
  10737. */
  10738. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10739. /**
  10740. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10741. */
  10742. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10743. /**
  10744. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10745. */
  10746. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10747. })(TextWrapping || (TextWrapping = {}));
  10748. /**
  10749. * Class used to create text block control
  10750. */
  10751. var TextBlock = /** @class */ (function (_super) {
  10752. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10753. /**
  10754. * Creates a new TextBlock object
  10755. * @param name defines the name of the control
  10756. * @param text defines the text to display (emptry string by default)
  10757. */
  10758. function TextBlock(
  10759. /**
  10760. * Defines the name of the control
  10761. */
  10762. name, text) {
  10763. if (text === void 0) { text = ""; }
  10764. var _this = _super.call(this, name) || this;
  10765. _this.name = name;
  10766. _this._text = "";
  10767. _this._textWrapping = TextWrapping.Clip;
  10768. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10769. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10770. _this._resizeToFit = false;
  10771. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10772. _this._outlineWidth = 0;
  10773. _this._outlineColor = "white";
  10774. /**
  10775. * An event triggered after the text is changed
  10776. */
  10777. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10778. /**
  10779. * An event triggered after the text was broken up into lines
  10780. */
  10781. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10782. _this.text = text;
  10783. return _this;
  10784. }
  10785. Object.defineProperty(TextBlock.prototype, "lines", {
  10786. /**
  10787. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10788. */
  10789. get: function () {
  10790. return this._lines;
  10791. },
  10792. enumerable: true,
  10793. configurable: true
  10794. });
  10795. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10796. /**
  10797. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10798. */
  10799. get: function () {
  10800. return this._resizeToFit;
  10801. },
  10802. /**
  10803. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10804. */
  10805. set: function (value) {
  10806. if (this._resizeToFit === value) {
  10807. return;
  10808. }
  10809. this._resizeToFit = value;
  10810. if (this._resizeToFit) {
  10811. this._width.ignoreAdaptiveScaling = true;
  10812. this._height.ignoreAdaptiveScaling = true;
  10813. }
  10814. this._markAsDirty();
  10815. },
  10816. enumerable: true,
  10817. configurable: true
  10818. });
  10819. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10820. /**
  10821. * Gets or sets a boolean indicating if text must be wrapped
  10822. */
  10823. get: function () {
  10824. return this._textWrapping;
  10825. },
  10826. /**
  10827. * Gets or sets a boolean indicating if text must be wrapped
  10828. */
  10829. set: function (value) {
  10830. if (this._textWrapping === value) {
  10831. return;
  10832. }
  10833. this._textWrapping = +value;
  10834. this._markAsDirty();
  10835. },
  10836. enumerable: true,
  10837. configurable: true
  10838. });
  10839. Object.defineProperty(TextBlock.prototype, "text", {
  10840. /**
  10841. * Gets or sets text to display
  10842. */
  10843. get: function () {
  10844. return this._text;
  10845. },
  10846. /**
  10847. * Gets or sets text to display
  10848. */
  10849. set: function (value) {
  10850. if (this._text === value) {
  10851. return;
  10852. }
  10853. this._text = value;
  10854. this._markAsDirty();
  10855. this.onTextChangedObservable.notifyObservers(this);
  10856. },
  10857. enumerable: true,
  10858. configurable: true
  10859. });
  10860. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10861. /**
  10862. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10863. */
  10864. get: function () {
  10865. return this._textHorizontalAlignment;
  10866. },
  10867. /**
  10868. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10869. */
  10870. set: function (value) {
  10871. if (this._textHorizontalAlignment === value) {
  10872. return;
  10873. }
  10874. this._textHorizontalAlignment = value;
  10875. this._markAsDirty();
  10876. },
  10877. enumerable: true,
  10878. configurable: true
  10879. });
  10880. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10881. /**
  10882. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10883. */
  10884. get: function () {
  10885. return this._textVerticalAlignment;
  10886. },
  10887. /**
  10888. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10889. */
  10890. set: function (value) {
  10891. if (this._textVerticalAlignment === value) {
  10892. return;
  10893. }
  10894. this._textVerticalAlignment = value;
  10895. this._markAsDirty();
  10896. },
  10897. enumerable: true,
  10898. configurable: true
  10899. });
  10900. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  10901. /**
  10902. * Gets or sets line spacing value
  10903. */
  10904. get: function () {
  10905. return this._lineSpacing.toString(this._host);
  10906. },
  10907. /**
  10908. * Gets or sets line spacing value
  10909. */
  10910. set: function (value) {
  10911. if (this._lineSpacing.fromString(value)) {
  10912. this._markAsDirty();
  10913. }
  10914. },
  10915. enumerable: true,
  10916. configurable: true
  10917. });
  10918. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  10919. /**
  10920. * Gets or sets outlineWidth of the text to display
  10921. */
  10922. get: function () {
  10923. return this._outlineWidth;
  10924. },
  10925. /**
  10926. * Gets or sets outlineWidth of the text to display
  10927. */
  10928. set: function (value) {
  10929. if (this._outlineWidth === value) {
  10930. return;
  10931. }
  10932. this._outlineWidth = value;
  10933. this._markAsDirty();
  10934. },
  10935. enumerable: true,
  10936. configurable: true
  10937. });
  10938. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  10939. /**
  10940. * Gets or sets outlineColor of the text to display
  10941. */
  10942. get: function () {
  10943. return this._outlineColor;
  10944. },
  10945. /**
  10946. * Gets or sets outlineColor of the text to display
  10947. */
  10948. set: function (value) {
  10949. if (this._outlineColor === value) {
  10950. return;
  10951. }
  10952. this._outlineColor = value;
  10953. this._markAsDirty();
  10954. },
  10955. enumerable: true,
  10956. configurable: true
  10957. });
  10958. TextBlock.prototype._getTypeName = function () {
  10959. return "TextBlock";
  10960. };
  10961. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  10962. if (!this._fontOffset) {
  10963. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  10964. }
  10965. _super.prototype._processMeasures.call(this, parentMeasure, context);
  10966. // Prepare lines
  10967. this._lines = this._breakLines(this._currentMeasure.width, context);
  10968. this.onLinesReadyObservable.notifyObservers(this);
  10969. var maxLineWidth = 0;
  10970. for (var i = 0; i < this._lines.length; i++) {
  10971. var line = this._lines[i];
  10972. if (line.width > maxLineWidth) {
  10973. maxLineWidth = line.width;
  10974. }
  10975. }
  10976. if (this._resizeToFit) {
  10977. if (this._textWrapping === TextWrapping.Clip) {
  10978. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  10979. if (newWidth !== this._width.internalValue) {
  10980. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  10981. this._rebuildLayout = true;
  10982. }
  10983. }
  10984. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  10985. if (newHeight !== this._height.internalValue) {
  10986. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  10987. this._rebuildLayout = true;
  10988. }
  10989. }
  10990. };
  10991. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  10992. var width = this._currentMeasure.width;
  10993. var x = 0;
  10994. switch (this._textHorizontalAlignment) {
  10995. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  10996. x = 0;
  10997. break;
  10998. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  10999. x = width - textWidth;
  11000. break;
  11001. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11002. x = (width - textWidth) / 2;
  11003. break;
  11004. }
  11005. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11006. context.shadowColor = this.shadowColor;
  11007. context.shadowBlur = this.shadowBlur;
  11008. context.shadowOffsetX = this.shadowOffsetX;
  11009. context.shadowOffsetY = this.shadowOffsetY;
  11010. }
  11011. if (this.outlineWidth) {
  11012. context.strokeText(text, this._currentMeasure.left + x, y);
  11013. }
  11014. context.fillText(text, this._currentMeasure.left + x, y);
  11015. };
  11016. /** @hidden */
  11017. TextBlock.prototype._draw = function (context) {
  11018. context.save();
  11019. this._applyStates(context);
  11020. // Render lines
  11021. this._renderLines(context);
  11022. context.restore();
  11023. };
  11024. TextBlock.prototype._applyStates = function (context) {
  11025. _super.prototype._applyStates.call(this, context);
  11026. if (this.outlineWidth) {
  11027. context.lineWidth = this.outlineWidth;
  11028. context.strokeStyle = this.outlineColor;
  11029. }
  11030. };
  11031. TextBlock.prototype._breakLines = function (refWidth, context) {
  11032. var lines = [];
  11033. var _lines = this.text.split("\n");
  11034. if (this._textWrapping === TextWrapping.Ellipsis) {
  11035. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11036. var _line = _lines_1[_i];
  11037. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11038. }
  11039. }
  11040. else if (this._textWrapping === TextWrapping.WordWrap) {
  11041. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11042. var _line = _lines_2[_a];
  11043. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11044. }
  11045. }
  11046. else {
  11047. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11048. var _line = _lines_3[_b];
  11049. lines.push(this._parseLine(_line, context));
  11050. }
  11051. }
  11052. return lines;
  11053. };
  11054. TextBlock.prototype._parseLine = function (line, context) {
  11055. if (line === void 0) { line = ''; }
  11056. return { text: line, width: context.measureText(line).width };
  11057. };
  11058. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11059. if (line === void 0) { line = ''; }
  11060. var lineWidth = context.measureText(line).width;
  11061. if (lineWidth > width) {
  11062. line += '…';
  11063. }
  11064. while (line.length > 2 && lineWidth > width) {
  11065. line = line.slice(0, -2) + '…';
  11066. lineWidth = context.measureText(line).width;
  11067. }
  11068. return { text: line, width: lineWidth };
  11069. };
  11070. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11071. if (line === void 0) { line = ''; }
  11072. var lines = [];
  11073. var words = line.split(' ');
  11074. var lineWidth = 0;
  11075. for (var n = 0; n < words.length; n++) {
  11076. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11077. var metrics = context.measureText(testLine);
  11078. var testWidth = metrics.width;
  11079. if (testWidth > width && n > 0) {
  11080. lines.push({ text: line, width: lineWidth });
  11081. line = words[n];
  11082. lineWidth = context.measureText(line).width;
  11083. }
  11084. else {
  11085. lineWidth = testWidth;
  11086. line = testLine;
  11087. }
  11088. }
  11089. lines.push({ text: line, width: lineWidth });
  11090. return lines;
  11091. };
  11092. TextBlock.prototype._renderLines = function (context) {
  11093. var height = this._currentMeasure.height;
  11094. var rootY = 0;
  11095. switch (this._textVerticalAlignment) {
  11096. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11097. rootY = this._fontOffset.ascent;
  11098. break;
  11099. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11100. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11101. break;
  11102. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11103. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11104. break;
  11105. }
  11106. rootY += this._currentMeasure.top;
  11107. for (var i = 0; i < this._lines.length; i++) {
  11108. var line = this._lines[i];
  11109. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11110. if (this._lineSpacing.isPixel) {
  11111. rootY += this._lineSpacing.getValue(this._host);
  11112. }
  11113. else {
  11114. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11115. }
  11116. }
  11117. this._drawText(line.text, line.width, rootY, context);
  11118. rootY += this._fontOffset.height;
  11119. }
  11120. };
  11121. /**
  11122. * Given a width constraint applied on the text block, find the expected height
  11123. * @returns expected height
  11124. */
  11125. TextBlock.prototype.computeExpectedHeight = function () {
  11126. if (this.text && this.widthInPixels) {
  11127. var context_1 = document.createElement('canvas').getContext('2d');
  11128. if (context_1) {
  11129. this._applyStates(context_1);
  11130. if (!this._fontOffset) {
  11131. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11132. }
  11133. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11134. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11135. }
  11136. }
  11137. return 0;
  11138. };
  11139. TextBlock.prototype.dispose = function () {
  11140. _super.prototype.dispose.call(this);
  11141. this.onTextChangedObservable.clear();
  11142. };
  11143. return TextBlock;
  11144. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11145. /***/ }),
  11146. /***/ "./2D/controls/virtualKeyboard.ts":
  11147. /*!****************************************!*\
  11148. !*** ./2D/controls/virtualKeyboard.ts ***!
  11149. \****************************************/
  11150. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11151. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11152. "use strict";
  11153. __webpack_require__.r(__webpack_exports__);
  11154. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11155. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11156. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11157. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs");
  11158. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11159. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11160. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11161. /**
  11162. * Class used to store key control properties
  11163. */
  11164. var KeyPropertySet = /** @class */ (function () {
  11165. function KeyPropertySet() {
  11166. }
  11167. return KeyPropertySet;
  11168. }());
  11169. /**
  11170. * Class used to create virtual keyboard
  11171. */
  11172. var VirtualKeyboard = /** @class */ (function (_super) {
  11173. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11174. function VirtualKeyboard() {
  11175. var _this = _super !== null && _super.apply(this, arguments) || this;
  11176. /** Observable raised when a key is pressed */
  11177. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11178. /** Gets or sets default key button width */
  11179. _this.defaultButtonWidth = "40px";
  11180. /** Gets or sets default key button height */
  11181. _this.defaultButtonHeight = "40px";
  11182. /** Gets or sets default key button left padding */
  11183. _this.defaultButtonPaddingLeft = "2px";
  11184. /** Gets or sets default key button right padding */
  11185. _this.defaultButtonPaddingRight = "2px";
  11186. /** Gets or sets default key button top padding */
  11187. _this.defaultButtonPaddingTop = "2px";
  11188. /** Gets or sets default key button bottom padding */
  11189. _this.defaultButtonPaddingBottom = "2px";
  11190. /** Gets or sets default key button foreground color */
  11191. _this.defaultButtonColor = "#DDD";
  11192. /** Gets or sets default key button background color */
  11193. _this.defaultButtonBackground = "#070707";
  11194. /** Gets or sets shift button foreground color */
  11195. _this.shiftButtonColor = "#7799FF";
  11196. /** Gets or sets shift button thickness*/
  11197. _this.selectedShiftThickness = 1;
  11198. /** Gets shift key state */
  11199. _this.shiftState = 0;
  11200. _this._currentlyConnectedInputText = null;
  11201. _this._connectedInputTexts = [];
  11202. _this._onKeyPressObserver = null;
  11203. return _this;
  11204. }
  11205. VirtualKeyboard.prototype._getTypeName = function () {
  11206. return "VirtualKeyboard";
  11207. };
  11208. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11209. var _this = this;
  11210. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11211. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11212. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11213. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11214. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11215. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11216. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11217. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11218. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11219. button.thickness = 0;
  11220. button.isFocusInvisible = true;
  11221. button.shadowColor = this.shadowColor;
  11222. button.shadowBlur = this.shadowBlur;
  11223. button.shadowOffsetX = this.shadowOffsetX;
  11224. button.shadowOffsetY = this.shadowOffsetY;
  11225. button.onPointerUpObservable.add(function () {
  11226. _this.onKeyPressObservable.notifyObservers(key);
  11227. });
  11228. return button;
  11229. };
  11230. /**
  11231. * Adds a new row of keys
  11232. * @param keys defines the list of keys to add
  11233. * @param propertySets defines the associated property sets
  11234. */
  11235. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11236. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11237. panel.isVertical = false;
  11238. panel.isFocusInvisible = true;
  11239. for (var i = 0; i < keys.length; i++) {
  11240. var properties = null;
  11241. if (propertySets && propertySets.length === keys.length) {
  11242. properties = propertySets[i];
  11243. }
  11244. panel.addControl(this._createKey(keys[i], properties));
  11245. }
  11246. this.addControl(panel);
  11247. };
  11248. /**
  11249. * Set the shift key to a specific state
  11250. * @param shiftState defines the new shift state
  11251. */
  11252. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11253. if (!this.children) {
  11254. return;
  11255. }
  11256. for (var i = 0; i < this.children.length; i++) {
  11257. var row = this.children[i];
  11258. if (!row || !row.children) {
  11259. continue;
  11260. }
  11261. var rowContainer = row;
  11262. for (var j = 0; j < rowContainer.children.length; j++) {
  11263. var button = rowContainer.children[j];
  11264. if (!button || !button.children[0]) {
  11265. continue;
  11266. }
  11267. var button_tblock = button.children[0];
  11268. if (button_tblock.text === "\u21E7") {
  11269. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11270. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11271. }
  11272. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11273. }
  11274. }
  11275. };
  11276. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11277. /** Gets the input text control currently attached to the keyboard */
  11278. get: function () {
  11279. return this._currentlyConnectedInputText;
  11280. },
  11281. enumerable: true,
  11282. configurable: true
  11283. });
  11284. /**
  11285. * Connects the keyboard with an input text control
  11286. *
  11287. * @param input defines the target control
  11288. */
  11289. VirtualKeyboard.prototype.connect = function (input) {
  11290. var _this = this;
  11291. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11292. if (inputTextAlreadyConnected) {
  11293. return;
  11294. }
  11295. if (this._onKeyPressObserver === null) {
  11296. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11297. if (!_this._currentlyConnectedInputText) {
  11298. return;
  11299. }
  11300. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11301. switch (key) {
  11302. case "\u21E7":
  11303. _this.shiftState++;
  11304. if (_this.shiftState > 2) {
  11305. _this.shiftState = 0;
  11306. }
  11307. _this.applyShiftState(_this.shiftState);
  11308. return;
  11309. case "\u2190":
  11310. _this._currentlyConnectedInputText.processKey(8);
  11311. return;
  11312. case "\u21B5":
  11313. _this._currentlyConnectedInputText.processKey(13);
  11314. return;
  11315. }
  11316. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11317. if (_this.shiftState === 1) {
  11318. _this.shiftState = 0;
  11319. _this.applyShiftState(_this.shiftState);
  11320. }
  11321. });
  11322. }
  11323. this.isVisible = false;
  11324. this._currentlyConnectedInputText = input;
  11325. input._connectedVirtualKeyboard = this;
  11326. // Events hooking
  11327. var onFocusObserver = input.onFocusObservable.add(function () {
  11328. _this._currentlyConnectedInputText = input;
  11329. input._connectedVirtualKeyboard = _this;
  11330. _this.isVisible = true;
  11331. });
  11332. var onBlurObserver = input.onBlurObservable.add(function () {
  11333. input._connectedVirtualKeyboard = null;
  11334. _this._currentlyConnectedInputText = null;
  11335. _this.isVisible = false;
  11336. });
  11337. this._connectedInputTexts.push({
  11338. input: input,
  11339. onBlurObserver: onBlurObserver,
  11340. onFocusObserver: onFocusObserver
  11341. });
  11342. };
  11343. /**
  11344. * Disconnects the keyboard from connected InputText controls
  11345. *
  11346. * @param input optionally defines a target control, otherwise all are disconnected
  11347. */
  11348. VirtualKeyboard.prototype.disconnect = function (input) {
  11349. var _this = this;
  11350. if (input) {
  11351. // .find not available on IE
  11352. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11353. if (filtered.length === 1) {
  11354. this._removeConnectedInputObservables(filtered[0]);
  11355. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11356. if (this._currentlyConnectedInputText === input) {
  11357. this._currentlyConnectedInputText = null;
  11358. }
  11359. }
  11360. }
  11361. else {
  11362. this._connectedInputTexts.forEach(function (connectedInputText) {
  11363. _this._removeConnectedInputObservables(connectedInputText);
  11364. });
  11365. this._connectedInputTexts = [];
  11366. }
  11367. if (this._connectedInputTexts.length === 0) {
  11368. this._currentlyConnectedInputText = null;
  11369. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11370. this._onKeyPressObserver = null;
  11371. }
  11372. };
  11373. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11374. connectedInputText.input._connectedVirtualKeyboard = null;
  11375. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11376. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11377. };
  11378. /**
  11379. * Release all resources
  11380. */
  11381. VirtualKeyboard.prototype.dispose = function () {
  11382. _super.prototype.dispose.call(this);
  11383. this.disconnect();
  11384. };
  11385. // Statics
  11386. /**
  11387. * Creates a new keyboard using a default layout
  11388. *
  11389. * @param name defines control name
  11390. * @returns a new VirtualKeyboard
  11391. */
  11392. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11393. var returnValue = new VirtualKeyboard(name);
  11394. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11395. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11396. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11397. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11398. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11399. return returnValue;
  11400. };
  11401. return VirtualKeyboard;
  11402. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11403. /***/ }),
  11404. /***/ "./2D/index.ts":
  11405. /*!*********************!*\
  11406. !*** ./2D/index.ts ***!
  11407. \*********************/
  11408. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, name */
  11409. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11410. "use strict";
  11411. __webpack_require__.r(__webpack_exports__);
  11412. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11444. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11446. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11448. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11451. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11453. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11455. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11457. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11459. /***/ }),
  11460. /***/ "./2D/math2D.ts":
  11461. /*!**********************!*\
  11462. !*** ./2D/math2D.ts ***!
  11463. \**********************/
  11464. /*! exports provided: Vector2WithInfo, Matrix2D */
  11465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11466. "use strict";
  11467. __webpack_require__.r(__webpack_exports__);
  11468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11470. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11471. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs");
  11472. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11473. /**
  11474. * Class used to transport Vector2 information for pointer events
  11475. */
  11476. var Vector2WithInfo = /** @class */ (function (_super) {
  11477. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11478. /**
  11479. * Creates a new Vector2WithInfo
  11480. * @param source defines the vector2 data to transport
  11481. * @param buttonIndex defines the current mouse button index
  11482. */
  11483. function Vector2WithInfo(source,
  11484. /** defines the current mouse button index */
  11485. buttonIndex) {
  11486. if (buttonIndex === void 0) { buttonIndex = 0; }
  11487. var _this = _super.call(this, source.x, source.y) || this;
  11488. _this.buttonIndex = buttonIndex;
  11489. return _this;
  11490. }
  11491. return Vector2WithInfo;
  11492. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11493. /** Class used to provide 2D matrix features */
  11494. var Matrix2D = /** @class */ (function () {
  11495. /**
  11496. * Creates a new matrix
  11497. * @param m00 defines value for (0, 0)
  11498. * @param m01 defines value for (0, 1)
  11499. * @param m10 defines value for (1, 0)
  11500. * @param m11 defines value for (1, 1)
  11501. * @param m20 defines value for (2, 0)
  11502. * @param m21 defines value for (2, 1)
  11503. */
  11504. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11505. /** Gets the internal array of 6 floats used to store matrix data */
  11506. this.m = new Float32Array(6);
  11507. this.fromValues(m00, m01, m10, m11, m20, m21);
  11508. }
  11509. /**
  11510. * Fills the matrix from direct values
  11511. * @param m00 defines value for (0, 0)
  11512. * @param m01 defines value for (0, 1)
  11513. * @param m10 defines value for (1, 0)
  11514. * @param m11 defines value for (1, 1)
  11515. * @param m20 defines value for (2, 0)
  11516. * @param m21 defines value for (2, 1)
  11517. * @returns the current modified matrix
  11518. */
  11519. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11520. this.m[0] = m00;
  11521. this.m[1] = m01;
  11522. this.m[2] = m10;
  11523. this.m[3] = m11;
  11524. this.m[4] = m20;
  11525. this.m[5] = m21;
  11526. return this;
  11527. };
  11528. /**
  11529. * Gets matrix determinant
  11530. * @returns the determinant
  11531. */
  11532. Matrix2D.prototype.determinant = function () {
  11533. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11534. };
  11535. /**
  11536. * Inverses the matrix and stores it in a target matrix
  11537. * @param result defines the target matrix
  11538. * @returns the current matrix
  11539. */
  11540. Matrix2D.prototype.invertToRef = function (result) {
  11541. var l0 = this.m[0];
  11542. var l1 = this.m[1];
  11543. var l2 = this.m[2];
  11544. var l3 = this.m[3];
  11545. var l4 = this.m[4];
  11546. var l5 = this.m[5];
  11547. var det = this.determinant();
  11548. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11549. result.m[0] = 0;
  11550. result.m[1] = 0;
  11551. result.m[2] = 0;
  11552. result.m[3] = 0;
  11553. result.m[4] = 0;
  11554. result.m[5] = 0;
  11555. return this;
  11556. }
  11557. var detDiv = 1 / det;
  11558. var det4 = l2 * l5 - l3 * l4;
  11559. var det5 = l1 * l4 - l0 * l5;
  11560. result.m[0] = l3 * detDiv;
  11561. result.m[1] = -l1 * detDiv;
  11562. result.m[2] = -l2 * detDiv;
  11563. result.m[3] = l0 * detDiv;
  11564. result.m[4] = det4 * detDiv;
  11565. result.m[5] = det5 * detDiv;
  11566. return this;
  11567. };
  11568. /**
  11569. * Multiplies the current matrix with another one
  11570. * @param other defines the second operand
  11571. * @param result defines the target matrix
  11572. * @returns the current matrix
  11573. */
  11574. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11575. var l0 = this.m[0];
  11576. var l1 = this.m[1];
  11577. var l2 = this.m[2];
  11578. var l3 = this.m[3];
  11579. var l4 = this.m[4];
  11580. var l5 = this.m[5];
  11581. var r0 = other.m[0];
  11582. var r1 = other.m[1];
  11583. var r2 = other.m[2];
  11584. var r3 = other.m[3];
  11585. var r4 = other.m[4];
  11586. var r5 = other.m[5];
  11587. result.m[0] = l0 * r0 + l1 * r2;
  11588. result.m[1] = l0 * r1 + l1 * r3;
  11589. result.m[2] = l2 * r0 + l3 * r2;
  11590. result.m[3] = l2 * r1 + l3 * r3;
  11591. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11592. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11593. return this;
  11594. };
  11595. /**
  11596. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11597. * @param x defines the x coordinate to transform
  11598. * @param y defines the x coordinate to transform
  11599. * @param result defines the target vector2
  11600. * @returns the current matrix
  11601. */
  11602. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11603. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11604. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11605. return this;
  11606. };
  11607. // Statics
  11608. /**
  11609. * Creates an identity matrix
  11610. * @returns a new matrix
  11611. */
  11612. Matrix2D.Identity = function () {
  11613. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11614. };
  11615. /**
  11616. * Creates a translation matrix and stores it in a target matrix
  11617. * @param x defines the x coordinate of the translation
  11618. * @param y defines the y coordinate of the translation
  11619. * @param result defines the target matrix
  11620. */
  11621. Matrix2D.TranslationToRef = function (x, y, result) {
  11622. result.fromValues(1, 0, 0, 1, x, y);
  11623. };
  11624. /**
  11625. * Creates a scaling matrix and stores it in a target matrix
  11626. * @param x defines the x coordinate of the scaling
  11627. * @param y defines the y coordinate of the scaling
  11628. * @param result defines the target matrix
  11629. */
  11630. Matrix2D.ScalingToRef = function (x, y, result) {
  11631. result.fromValues(x, 0, 0, y, 0, 0);
  11632. };
  11633. /**
  11634. * Creates a rotation matrix and stores it in a target matrix
  11635. * @param angle defines the rotation angle
  11636. * @param result defines the target matrix
  11637. */
  11638. Matrix2D.RotationToRef = function (angle, result) {
  11639. var s = Math.sin(angle);
  11640. var c = Math.cos(angle);
  11641. result.fromValues(c, s, -s, c, 0, 0);
  11642. };
  11643. /**
  11644. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11645. * @param tx defines the x coordinate of the translation
  11646. * @param ty defines the y coordinate of the translation
  11647. * @param angle defines the rotation angle
  11648. * @param scaleX defines the x coordinate of the scaling
  11649. * @param scaleY defines the y coordinate of the scaling
  11650. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11651. * @param result defines the target matrix
  11652. */
  11653. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11654. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11655. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11656. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11657. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11658. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11659. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11660. if (parentMatrix) {
  11661. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11662. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11663. }
  11664. else {
  11665. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11666. }
  11667. };
  11668. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11669. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11670. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11671. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11672. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11673. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11674. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11675. return Matrix2D;
  11676. }());
  11677. /***/ }),
  11678. /***/ "./2D/measure.ts":
  11679. /*!***********************!*\
  11680. !*** ./2D/measure.ts ***!
  11681. \***********************/
  11682. /*! exports provided: Measure */
  11683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11684. "use strict";
  11685. __webpack_require__.r(__webpack_exports__);
  11686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11687. /* harmony import */ var babylonjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs */ "babylonjs");
  11688. /* harmony import */ var babylonjs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs__WEBPACK_IMPORTED_MODULE_0__);
  11689. /**
  11690. * Class used to store 2D control sizes
  11691. */
  11692. var Measure = /** @class */ (function () {
  11693. /**
  11694. * Creates a new measure
  11695. * @param left defines left coordinate
  11696. * @param top defines top coordinate
  11697. * @param width defines width dimension
  11698. * @param height defines height dimension
  11699. */
  11700. function Measure(
  11701. /** defines left coordinate */
  11702. left,
  11703. /** defines top coordinate */
  11704. top,
  11705. /** defines width dimension */
  11706. width,
  11707. /** defines height dimension */
  11708. height) {
  11709. this.left = left;
  11710. this.top = top;
  11711. this.width = width;
  11712. this.height = height;
  11713. }
  11714. /**
  11715. * Copy from another measure
  11716. * @param other defines the other measure to copy from
  11717. */
  11718. Measure.prototype.copyFrom = function (other) {
  11719. this.left = other.left;
  11720. this.top = other.top;
  11721. this.width = other.width;
  11722. this.height = other.height;
  11723. };
  11724. /**
  11725. * Copy from a group of 4 floats
  11726. * @param left defines left coordinate
  11727. * @param top defines top coordinate
  11728. * @param width defines width dimension
  11729. * @param height defines height dimension
  11730. */
  11731. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11732. this.left = left;
  11733. this.top = top;
  11734. this.width = width;
  11735. this.height = height;
  11736. };
  11737. /**
  11738. * Computes the axis aligned bounding box measure for two given measures
  11739. * @param a Input measure
  11740. * @param b Input measure
  11741. * @param result the resulting bounding measure
  11742. */
  11743. Measure.CombineToRef = function (a, b, result) {
  11744. var left = Math.min(a.left, b.left);
  11745. var top = Math.min(a.top, b.top);
  11746. var right = Math.max(a.left + a.width, b.left + b.width);
  11747. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11748. result.left = left;
  11749. result.top = top;
  11750. result.width = right - left;
  11751. result.height = bottom - top;
  11752. };
  11753. /**
  11754. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11755. * @param transform the matrix to transform the measure before computing the AABB
  11756. * @param result the resulting AABB
  11757. */
  11758. Measure.prototype.transformToRef = function (transform, result) {
  11759. var rectanglePoints = babylonjs__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11760. var min = new babylonjs__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11761. var max = new babylonjs__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11762. for (var i = 0; i < 4; i++) {
  11763. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11764. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11765. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11766. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11767. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11768. }
  11769. result.left = min.x;
  11770. result.top = min.y;
  11771. result.width = max.x - min.x;
  11772. result.height = max.y - min.y;
  11773. };
  11774. /**
  11775. * Check equality between this measure and another one
  11776. * @param other defines the other measures
  11777. * @returns true if both measures are equals
  11778. */
  11779. Measure.prototype.isEqualsTo = function (other) {
  11780. if (this.left !== other.left) {
  11781. return false;
  11782. }
  11783. if (this.top !== other.top) {
  11784. return false;
  11785. }
  11786. if (this.width !== other.width) {
  11787. return false;
  11788. }
  11789. if (this.height !== other.height) {
  11790. return false;
  11791. }
  11792. return true;
  11793. };
  11794. /**
  11795. * Creates an empty measure
  11796. * @returns a new measure
  11797. */
  11798. Measure.Empty = function () {
  11799. return new Measure(0, 0, 0, 0);
  11800. };
  11801. return Measure;
  11802. }());
  11803. /***/ }),
  11804. /***/ "./2D/multiLinePoint.ts":
  11805. /*!******************************!*\
  11806. !*** ./2D/multiLinePoint.ts ***!
  11807. \******************************/
  11808. /*! exports provided: MultiLinePoint */
  11809. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11810. "use strict";
  11811. __webpack_require__.r(__webpack_exports__);
  11812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11813. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs");
  11814. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11815. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11816. /**
  11817. * Class used to store a point for a MultiLine object.
  11818. * The point can be pure 2D coordinates, a mesh or a control
  11819. */
  11820. var MultiLinePoint = /** @class */ (function () {
  11821. /**
  11822. * Creates a new MultiLinePoint
  11823. * @param multiLine defines the source MultiLine object
  11824. */
  11825. function MultiLinePoint(multiLine) {
  11826. this._multiLine = multiLine;
  11827. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11828. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11829. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11830. }
  11831. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11832. /** Gets or sets x coordinate */
  11833. get: function () {
  11834. return this._x.toString(this._multiLine._host);
  11835. },
  11836. set: function (value) {
  11837. if (this._x.toString(this._multiLine._host) === value) {
  11838. return;
  11839. }
  11840. if (this._x.fromString(value)) {
  11841. this._multiLine._markAsDirty();
  11842. }
  11843. },
  11844. enumerable: true,
  11845. configurable: true
  11846. });
  11847. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11848. /** Gets or sets y coordinate */
  11849. get: function () {
  11850. return this._y.toString(this._multiLine._host);
  11851. },
  11852. set: function (value) {
  11853. if (this._y.toString(this._multiLine._host) === value) {
  11854. return;
  11855. }
  11856. if (this._y.fromString(value)) {
  11857. this._multiLine._markAsDirty();
  11858. }
  11859. },
  11860. enumerable: true,
  11861. configurable: true
  11862. });
  11863. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11864. /** Gets or sets the control associated with this point */
  11865. get: function () {
  11866. return this._control;
  11867. },
  11868. set: function (value) {
  11869. if (this._control === value) {
  11870. return;
  11871. }
  11872. if (this._control && this._controlObserver) {
  11873. this._control.onDirtyObservable.remove(this._controlObserver);
  11874. this._controlObserver = null;
  11875. }
  11876. this._control = value;
  11877. if (this._control) {
  11878. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  11879. }
  11880. this._multiLine._markAsDirty();
  11881. },
  11882. enumerable: true,
  11883. configurable: true
  11884. });
  11885. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  11886. /** Gets or sets the mesh associated with this point */
  11887. get: function () {
  11888. return this._mesh;
  11889. },
  11890. set: function (value) {
  11891. if (this._mesh === value) {
  11892. return;
  11893. }
  11894. if (this._mesh && this._meshObserver) {
  11895. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  11896. }
  11897. this._mesh = value;
  11898. if (this._mesh) {
  11899. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  11900. }
  11901. this._multiLine._markAsDirty();
  11902. },
  11903. enumerable: true,
  11904. configurable: true
  11905. });
  11906. /** Resets links */
  11907. MultiLinePoint.prototype.resetLinks = function () {
  11908. this.control = null;
  11909. this.mesh = null;
  11910. };
  11911. /**
  11912. * Gets a translation vector
  11913. * @returns the translation vector
  11914. */
  11915. MultiLinePoint.prototype.translate = function () {
  11916. this._point = this._translatePoint();
  11917. return this._point;
  11918. };
  11919. MultiLinePoint.prototype._translatePoint = function () {
  11920. if (this._mesh != null) {
  11921. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  11922. }
  11923. else if (this._control != null) {
  11924. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  11925. }
  11926. else {
  11927. var host = this._multiLine._host;
  11928. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  11929. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  11930. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  11931. }
  11932. };
  11933. /** Release associated resources */
  11934. MultiLinePoint.prototype.dispose = function () {
  11935. this.resetLinks();
  11936. };
  11937. return MultiLinePoint;
  11938. }());
  11939. /***/ }),
  11940. /***/ "./2D/style.ts":
  11941. /*!*********************!*\
  11942. !*** ./2D/style.ts ***!
  11943. \*********************/
  11944. /*! exports provided: Style */
  11945. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11946. "use strict";
  11947. __webpack_require__.r(__webpack_exports__);
  11948. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  11949. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs");
  11950. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  11951. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11952. /**
  11953. * Define a style used by control to automatically setup properties based on a template.
  11954. * Only support font related properties so far
  11955. */
  11956. var Style = /** @class */ (function () {
  11957. /**
  11958. * Creates a new style object
  11959. * @param host defines the AdvancedDynamicTexture which hosts this style
  11960. */
  11961. function Style(host) {
  11962. this._fontFamily = "Arial";
  11963. this._fontStyle = "";
  11964. this._fontWeight = "";
  11965. /** @hidden */
  11966. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  11967. /**
  11968. * Observable raised when the style values are changed
  11969. */
  11970. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  11971. this._host = host;
  11972. }
  11973. Object.defineProperty(Style.prototype, "fontSize", {
  11974. /**
  11975. * Gets or sets the font size
  11976. */
  11977. get: function () {
  11978. return this._fontSize.toString(this._host);
  11979. },
  11980. set: function (value) {
  11981. if (this._fontSize.toString(this._host) === value) {
  11982. return;
  11983. }
  11984. if (this._fontSize.fromString(value)) {
  11985. this.onChangedObservable.notifyObservers(this);
  11986. }
  11987. },
  11988. enumerable: true,
  11989. configurable: true
  11990. });
  11991. Object.defineProperty(Style.prototype, "fontFamily", {
  11992. /**
  11993. * Gets or sets the font family
  11994. */
  11995. get: function () {
  11996. return this._fontFamily;
  11997. },
  11998. set: function (value) {
  11999. if (this._fontFamily === value) {
  12000. return;
  12001. }
  12002. this._fontFamily = value;
  12003. this.onChangedObservable.notifyObservers(this);
  12004. },
  12005. enumerable: true,
  12006. configurable: true
  12007. });
  12008. Object.defineProperty(Style.prototype, "fontStyle", {
  12009. /**
  12010. * Gets or sets the font style
  12011. */
  12012. get: function () {
  12013. return this._fontStyle;
  12014. },
  12015. set: function (value) {
  12016. if (this._fontStyle === value) {
  12017. return;
  12018. }
  12019. this._fontStyle = value;
  12020. this.onChangedObservable.notifyObservers(this);
  12021. },
  12022. enumerable: true,
  12023. configurable: true
  12024. });
  12025. Object.defineProperty(Style.prototype, "fontWeight", {
  12026. /** Gets or sets font weight */
  12027. get: function () {
  12028. return this._fontWeight;
  12029. },
  12030. set: function (value) {
  12031. if (this._fontWeight === value) {
  12032. return;
  12033. }
  12034. this._fontWeight = value;
  12035. this.onChangedObservable.notifyObservers(this);
  12036. },
  12037. enumerable: true,
  12038. configurable: true
  12039. });
  12040. /** Dispose all associated resources */
  12041. Style.prototype.dispose = function () {
  12042. this.onChangedObservable.clear();
  12043. };
  12044. return Style;
  12045. }());
  12046. /***/ }),
  12047. /***/ "./2D/valueAndUnit.ts":
  12048. /*!****************************!*\
  12049. !*** ./2D/valueAndUnit.ts ***!
  12050. \****************************/
  12051. /*! exports provided: ValueAndUnit */
  12052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12053. "use strict";
  12054. __webpack_require__.r(__webpack_exports__);
  12055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12056. /**
  12057. * Class used to specific a value and its associated unit
  12058. */
  12059. var ValueAndUnit = /** @class */ (function () {
  12060. /**
  12061. * Creates a new ValueAndUnit
  12062. * @param value defines the value to store
  12063. * @param unit defines the unit to store
  12064. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12065. */
  12066. function ValueAndUnit(value,
  12067. /** defines the unit to store */
  12068. unit,
  12069. /** defines a boolean indicating if the value can be negative */
  12070. negativeValueAllowed) {
  12071. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12072. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12073. this.unit = unit;
  12074. this.negativeValueAllowed = negativeValueAllowed;
  12075. this._value = 1;
  12076. /**
  12077. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12078. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12079. */
  12080. this.ignoreAdaptiveScaling = false;
  12081. this._value = value;
  12082. this._originalUnit = unit;
  12083. }
  12084. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12085. /** Gets a boolean indicating if the value is a percentage */
  12086. get: function () {
  12087. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12088. },
  12089. enumerable: true,
  12090. configurable: true
  12091. });
  12092. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12093. /** Gets a boolean indicating if the value is store as pixel */
  12094. get: function () {
  12095. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12096. },
  12097. enumerable: true,
  12098. configurable: true
  12099. });
  12100. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12101. /** Gets direct internal value */
  12102. get: function () {
  12103. return this._value;
  12104. },
  12105. enumerable: true,
  12106. configurable: true
  12107. });
  12108. /**
  12109. * Gets value as pixel
  12110. * @param host defines the root host
  12111. * @param refValue defines the reference value for percentages
  12112. * @returns the value as pixel
  12113. */
  12114. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12115. if (this.isPixel) {
  12116. return this.getValue(host);
  12117. }
  12118. return this.getValue(host) * refValue;
  12119. };
  12120. /**
  12121. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12122. * @param value defines the value to store
  12123. * @param unit defines the unit to store
  12124. * @returns the current ValueAndUnit
  12125. */
  12126. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12127. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12128. this._value = value;
  12129. this.unit = unit;
  12130. return this;
  12131. };
  12132. /**
  12133. * Gets the value accordingly to its unit
  12134. * @param host defines the root host
  12135. * @returns the value
  12136. */
  12137. ValueAndUnit.prototype.getValue = function (host) {
  12138. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12139. var width = 0;
  12140. var height = 0;
  12141. if (host.idealWidth) {
  12142. width = (this._value * host.getSize().width) / host.idealWidth;
  12143. }
  12144. if (host.idealHeight) {
  12145. height = (this._value * host.getSize().height) / host.idealHeight;
  12146. }
  12147. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12148. return window.innerWidth < window.innerHeight ? width : height;
  12149. }
  12150. if (host.idealWidth) { // horizontal
  12151. return width;
  12152. }
  12153. if (host.idealHeight) { // vertical
  12154. return height;
  12155. }
  12156. }
  12157. return this._value;
  12158. };
  12159. /**
  12160. * Gets a string representation of the value
  12161. * @param host defines the root host
  12162. * @returns a string
  12163. */
  12164. ValueAndUnit.prototype.toString = function (host) {
  12165. switch (this.unit) {
  12166. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12167. return (this.getValue(host) * 100) + "%";
  12168. case ValueAndUnit.UNITMODE_PIXEL:
  12169. return this.getValue(host) + "px";
  12170. }
  12171. return this.unit.toString();
  12172. };
  12173. /**
  12174. * Store a value parsed from a string
  12175. * @param source defines the source string
  12176. * @returns true if the value was successfully parsed
  12177. */
  12178. ValueAndUnit.prototype.fromString = function (source) {
  12179. var match = ValueAndUnit._Regex.exec(source.toString());
  12180. if (!match || match.length === 0) {
  12181. return false;
  12182. }
  12183. var sourceValue = parseFloat(match[1]);
  12184. var sourceUnit = this._originalUnit;
  12185. if (!this.negativeValueAllowed) {
  12186. if (sourceValue < 0) {
  12187. sourceValue = 0;
  12188. }
  12189. }
  12190. if (match.length === 4) {
  12191. switch (match[3]) {
  12192. case "px":
  12193. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12194. break;
  12195. case "%":
  12196. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12197. sourceValue /= 100.0;
  12198. break;
  12199. }
  12200. }
  12201. if (sourceValue === this._value && sourceUnit === this.unit) {
  12202. return false;
  12203. }
  12204. this._value = sourceValue;
  12205. this.unit = sourceUnit;
  12206. return true;
  12207. };
  12208. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12209. /** UNITMODE_PERCENTAGE */
  12210. get: function () {
  12211. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12212. },
  12213. enumerable: true,
  12214. configurable: true
  12215. });
  12216. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12217. /** UNITMODE_PIXEL */
  12218. get: function () {
  12219. return ValueAndUnit._UNITMODE_PIXEL;
  12220. },
  12221. enumerable: true,
  12222. configurable: true
  12223. });
  12224. // Static
  12225. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12226. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12227. ValueAndUnit._UNITMODE_PIXEL = 1;
  12228. return ValueAndUnit;
  12229. }());
  12230. /***/ }),
  12231. /***/ "./3D/controls/abstractButton3D.ts":
  12232. /*!*****************************************!*\
  12233. !*** ./3D/controls/abstractButton3D.ts ***!
  12234. \*****************************************/
  12235. /*! exports provided: AbstractButton3D */
  12236. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12237. "use strict";
  12238. __webpack_require__.r(__webpack_exports__);
  12239. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12240. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12241. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs");
  12242. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12243. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12244. /**
  12245. * Class used as a root to all buttons
  12246. */
  12247. var AbstractButton3D = /** @class */ (function (_super) {
  12248. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12249. /**
  12250. * Creates a new button
  12251. * @param name defines the control name
  12252. */
  12253. function AbstractButton3D(name) {
  12254. return _super.call(this, name) || this;
  12255. }
  12256. AbstractButton3D.prototype._getTypeName = function () {
  12257. return "AbstractButton3D";
  12258. };
  12259. // Mesh association
  12260. AbstractButton3D.prototype._createNode = function (scene) {
  12261. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12262. };
  12263. return AbstractButton3D;
  12264. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12265. /***/ }),
  12266. /***/ "./3D/controls/button3D.ts":
  12267. /*!*********************************!*\
  12268. !*** ./3D/controls/button3D.ts ***!
  12269. \*********************************/
  12270. /*! exports provided: Button3D */
  12271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12272. "use strict";
  12273. __webpack_require__.r(__webpack_exports__);
  12274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12275. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12276. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs");
  12277. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12278. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12279. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12280. /**
  12281. * Class used to create a button in 3D
  12282. */
  12283. var Button3D = /** @class */ (function (_super) {
  12284. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12285. /**
  12286. * Creates a new button
  12287. * @param name defines the control name
  12288. */
  12289. function Button3D(name) {
  12290. var _this = _super.call(this, name) || this;
  12291. _this._contentResolution = 512;
  12292. _this._contentScaleRatio = 2;
  12293. // Default animations
  12294. _this.pointerEnterAnimation = function () {
  12295. if (!_this.mesh) {
  12296. return;
  12297. }
  12298. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12299. };
  12300. _this.pointerOutAnimation = function () {
  12301. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12302. };
  12303. _this.pointerDownAnimation = function () {
  12304. if (!_this.mesh) {
  12305. return;
  12306. }
  12307. _this.mesh.scaling.scaleInPlace(0.95);
  12308. };
  12309. _this.pointerUpAnimation = function () {
  12310. if (!_this.mesh) {
  12311. return;
  12312. }
  12313. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12314. };
  12315. return _this;
  12316. }
  12317. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12318. /**
  12319. * Gets or sets the texture resolution used to render content (512 by default)
  12320. */
  12321. get: function () {
  12322. return this._contentResolution;
  12323. },
  12324. set: function (value) {
  12325. if (this._contentResolution === value) {
  12326. return;
  12327. }
  12328. this._contentResolution = value;
  12329. this._resetContent();
  12330. },
  12331. enumerable: true,
  12332. configurable: true
  12333. });
  12334. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12335. /**
  12336. * Gets or sets the texture scale ratio used to render content (2 by default)
  12337. */
  12338. get: function () {
  12339. return this._contentScaleRatio;
  12340. },
  12341. set: function (value) {
  12342. if (this._contentScaleRatio === value) {
  12343. return;
  12344. }
  12345. this._contentScaleRatio = value;
  12346. this._resetContent();
  12347. },
  12348. enumerable: true,
  12349. configurable: true
  12350. });
  12351. Button3D.prototype._disposeFacadeTexture = function () {
  12352. if (this._facadeTexture) {
  12353. this._facadeTexture.dispose();
  12354. this._facadeTexture = null;
  12355. }
  12356. };
  12357. Button3D.prototype._resetContent = function () {
  12358. this._disposeFacadeTexture();
  12359. this.content = this._content;
  12360. };
  12361. Object.defineProperty(Button3D.prototype, "content", {
  12362. /**
  12363. * Gets or sets the GUI 2D content used to display the button's facade
  12364. */
  12365. get: function () {
  12366. return this._content;
  12367. },
  12368. set: function (value) {
  12369. this._content = value;
  12370. if (!this._host || !this._host.utilityLayer) {
  12371. return;
  12372. }
  12373. if (!this._facadeTexture) {
  12374. 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);
  12375. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12376. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12377. this._facadeTexture.premulAlpha = true;
  12378. }
  12379. this._facadeTexture.addControl(value);
  12380. this._applyFacade(this._facadeTexture);
  12381. },
  12382. enumerable: true,
  12383. configurable: true
  12384. });
  12385. /**
  12386. * Apply the facade texture (created from the content property).
  12387. * This function can be overloaded by child classes
  12388. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12389. */
  12390. Button3D.prototype._applyFacade = function (facadeTexture) {
  12391. this._currentMaterial.emissiveTexture = facadeTexture;
  12392. };
  12393. Button3D.prototype._getTypeName = function () {
  12394. return "Button3D";
  12395. };
  12396. // Mesh association
  12397. Button3D.prototype._createNode = function (scene) {
  12398. var faceUV = new Array(6);
  12399. for (var i = 0; i < 6; i++) {
  12400. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12401. }
  12402. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12403. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12404. width: 1.0,
  12405. height: 1.0,
  12406. depth: 0.08,
  12407. faceUV: faceUV
  12408. }, scene);
  12409. return mesh;
  12410. };
  12411. Button3D.prototype._affectMaterial = function (mesh) {
  12412. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12413. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12414. mesh.material = material;
  12415. this._currentMaterial = material;
  12416. this._resetContent();
  12417. };
  12418. /**
  12419. * Releases all associated resources
  12420. */
  12421. Button3D.prototype.dispose = function () {
  12422. _super.prototype.dispose.call(this);
  12423. this._disposeFacadeTexture();
  12424. if (this._currentMaterial) {
  12425. this._currentMaterial.dispose();
  12426. }
  12427. };
  12428. return Button3D;
  12429. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12430. /***/ }),
  12431. /***/ "./3D/controls/container3D.ts":
  12432. /*!************************************!*\
  12433. !*** ./3D/controls/container3D.ts ***!
  12434. \************************************/
  12435. /*! exports provided: Container3D */
  12436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12437. "use strict";
  12438. __webpack_require__.r(__webpack_exports__);
  12439. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12440. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12441. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs");
  12442. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12443. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12444. /**
  12445. * Class used to create containers for controls
  12446. */
  12447. var Container3D = /** @class */ (function (_super) {
  12448. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12449. /**
  12450. * Creates a new container
  12451. * @param name defines the container name
  12452. */
  12453. function Container3D(name) {
  12454. var _this = _super.call(this, name) || this;
  12455. _this._blockLayout = false;
  12456. /**
  12457. * Gets the list of child controls
  12458. */
  12459. _this._children = new Array();
  12460. return _this;
  12461. }
  12462. Object.defineProperty(Container3D.prototype, "children", {
  12463. /**
  12464. * Gets the list of child controls
  12465. */
  12466. get: function () {
  12467. return this._children;
  12468. },
  12469. enumerable: true,
  12470. configurable: true
  12471. });
  12472. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12473. /**
  12474. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12475. * This is helpful to optimize layout operation when adding multiple children in a row
  12476. */
  12477. get: function () {
  12478. return this._blockLayout;
  12479. },
  12480. set: function (value) {
  12481. if (this._blockLayout === value) {
  12482. return;
  12483. }
  12484. this._blockLayout = value;
  12485. if (!this._blockLayout) {
  12486. this._arrangeChildren();
  12487. }
  12488. },
  12489. enumerable: true,
  12490. configurable: true
  12491. });
  12492. /**
  12493. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12494. * @returns the current container
  12495. */
  12496. Container3D.prototype.updateLayout = function () {
  12497. this._arrangeChildren();
  12498. return this;
  12499. };
  12500. /**
  12501. * Gets a boolean indicating if the given control is in the children of this control
  12502. * @param control defines the control to check
  12503. * @returns true if the control is in the child list
  12504. */
  12505. Container3D.prototype.containsControl = function (control) {
  12506. return this._children.indexOf(control) !== -1;
  12507. };
  12508. /**
  12509. * Adds a control to the children of this control
  12510. * @param control defines the control to add
  12511. * @returns the current container
  12512. */
  12513. Container3D.prototype.addControl = function (control) {
  12514. var index = this._children.indexOf(control);
  12515. if (index !== -1) {
  12516. return this;
  12517. }
  12518. control.parent = this;
  12519. control._host = this._host;
  12520. this._children.push(control);
  12521. if (this._host.utilityLayer) {
  12522. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12523. if (control.node) {
  12524. control.node.parent = this.node;
  12525. }
  12526. if (!this.blockLayout) {
  12527. this._arrangeChildren();
  12528. }
  12529. }
  12530. return this;
  12531. };
  12532. /**
  12533. * This function will be called everytime a new control is added
  12534. */
  12535. Container3D.prototype._arrangeChildren = function () {
  12536. };
  12537. Container3D.prototype._createNode = function (scene) {
  12538. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12539. };
  12540. /**
  12541. * Removes a control from the children of this control
  12542. * @param control defines the control to remove
  12543. * @returns the current container
  12544. */
  12545. Container3D.prototype.removeControl = function (control) {
  12546. var index = this._children.indexOf(control);
  12547. if (index !== -1) {
  12548. this._children.splice(index, 1);
  12549. control.parent = null;
  12550. control._disposeNode();
  12551. }
  12552. return this;
  12553. };
  12554. Container3D.prototype._getTypeName = function () {
  12555. return "Container3D";
  12556. };
  12557. /**
  12558. * Releases all associated resources
  12559. */
  12560. Container3D.prototype.dispose = function () {
  12561. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12562. var control = _a[_i];
  12563. control.dispose();
  12564. }
  12565. this._children = [];
  12566. _super.prototype.dispose.call(this);
  12567. };
  12568. /** Control rotation will remain unchanged */
  12569. Container3D.UNSET_ORIENTATION = 0;
  12570. /** Control will rotate to make it look at sphere central axis */
  12571. Container3D.FACEORIGIN_ORIENTATION = 1;
  12572. /** Control will rotate to make it look back at sphere central axis */
  12573. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12574. /** Control will rotate to look at z axis (0, 0, 1) */
  12575. Container3D.FACEFORWARD_ORIENTATION = 3;
  12576. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12577. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12578. return Container3D;
  12579. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12580. /***/ }),
  12581. /***/ "./3D/controls/control3D.ts":
  12582. /*!**********************************!*\
  12583. !*** ./3D/controls/control3D.ts ***!
  12584. \**********************************/
  12585. /*! exports provided: Control3D */
  12586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12587. "use strict";
  12588. __webpack_require__.r(__webpack_exports__);
  12589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12590. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs");
  12591. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12592. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12593. /**
  12594. * Class used as base class for controls
  12595. */
  12596. var Control3D = /** @class */ (function () {
  12597. /**
  12598. * Creates a new control
  12599. * @param name defines the control name
  12600. */
  12601. function Control3D(
  12602. /** Defines the control name */
  12603. name) {
  12604. this.name = name;
  12605. this._downCount = 0;
  12606. this._enterCount = -1;
  12607. this._downPointerIds = {};
  12608. this._isVisible = true;
  12609. /**
  12610. * An event triggered when the pointer move over the control
  12611. */
  12612. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12613. /**
  12614. * An event triggered when the pointer move out of the control
  12615. */
  12616. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12617. /**
  12618. * An event triggered when the pointer taps the control
  12619. */
  12620. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12621. /**
  12622. * An event triggered when pointer is up
  12623. */
  12624. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12625. /**
  12626. * An event triggered when a control is clicked on (with a mouse)
  12627. */
  12628. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12629. /**
  12630. * An event triggered when pointer enters the control
  12631. */
  12632. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12633. // Behaviors
  12634. this._behaviors = new Array();
  12635. }
  12636. Object.defineProperty(Control3D.prototype, "position", {
  12637. /** Gets or sets the control position in world space */
  12638. get: function () {
  12639. if (!this._node) {
  12640. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12641. }
  12642. return this._node.position;
  12643. },
  12644. set: function (value) {
  12645. if (!this._node) {
  12646. return;
  12647. }
  12648. this._node.position = value;
  12649. },
  12650. enumerable: true,
  12651. configurable: true
  12652. });
  12653. Object.defineProperty(Control3D.prototype, "scaling", {
  12654. /** Gets or sets the control scaling in world space */
  12655. get: function () {
  12656. if (!this._node) {
  12657. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12658. }
  12659. return this._node.scaling;
  12660. },
  12661. set: function (value) {
  12662. if (!this._node) {
  12663. return;
  12664. }
  12665. this._node.scaling = value;
  12666. },
  12667. enumerable: true,
  12668. configurable: true
  12669. });
  12670. Object.defineProperty(Control3D.prototype, "behaviors", {
  12671. /**
  12672. * Gets the list of attached behaviors
  12673. * @see http://doc.babylonjs.com/features/behaviour
  12674. */
  12675. get: function () {
  12676. return this._behaviors;
  12677. },
  12678. enumerable: true,
  12679. configurable: true
  12680. });
  12681. /**
  12682. * Attach a behavior to the control
  12683. * @see http://doc.babylonjs.com/features/behaviour
  12684. * @param behavior defines the behavior to attach
  12685. * @returns the current control
  12686. */
  12687. Control3D.prototype.addBehavior = function (behavior) {
  12688. var _this = this;
  12689. var index = this._behaviors.indexOf(behavior);
  12690. if (index !== -1) {
  12691. return this;
  12692. }
  12693. behavior.init();
  12694. var scene = this._host.scene;
  12695. if (scene.isLoading) {
  12696. // We defer the attach when the scene will be loaded
  12697. scene.onDataLoadedObservable.addOnce(function () {
  12698. behavior.attach(_this);
  12699. });
  12700. }
  12701. else {
  12702. behavior.attach(this);
  12703. }
  12704. this._behaviors.push(behavior);
  12705. return this;
  12706. };
  12707. /**
  12708. * Remove an attached behavior
  12709. * @see http://doc.babylonjs.com/features/behaviour
  12710. * @param behavior defines the behavior to attach
  12711. * @returns the current control
  12712. */
  12713. Control3D.prototype.removeBehavior = function (behavior) {
  12714. var index = this._behaviors.indexOf(behavior);
  12715. if (index === -1) {
  12716. return this;
  12717. }
  12718. this._behaviors[index].detach();
  12719. this._behaviors.splice(index, 1);
  12720. return this;
  12721. };
  12722. /**
  12723. * Gets an attached behavior by name
  12724. * @param name defines the name of the behavior to look for
  12725. * @see http://doc.babylonjs.com/features/behaviour
  12726. * @returns null if behavior was not found else the requested behavior
  12727. */
  12728. Control3D.prototype.getBehaviorByName = function (name) {
  12729. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12730. var behavior = _a[_i];
  12731. if (behavior.name === name) {
  12732. return behavior;
  12733. }
  12734. }
  12735. return null;
  12736. };
  12737. Object.defineProperty(Control3D.prototype, "isVisible", {
  12738. /** Gets or sets a boolean indicating if the control is visible */
  12739. get: function () {
  12740. return this._isVisible;
  12741. },
  12742. set: function (value) {
  12743. if (this._isVisible === value) {
  12744. return;
  12745. }
  12746. this._isVisible = value;
  12747. var mesh = this.mesh;
  12748. if (mesh) {
  12749. mesh.setEnabled(value);
  12750. }
  12751. },
  12752. enumerable: true,
  12753. configurable: true
  12754. });
  12755. Object.defineProperty(Control3D.prototype, "typeName", {
  12756. /**
  12757. * Gets a string representing the class name
  12758. */
  12759. get: function () {
  12760. return this._getTypeName();
  12761. },
  12762. enumerable: true,
  12763. configurable: true
  12764. });
  12765. /**
  12766. * Get the current class name of the control.
  12767. * @returns current class name
  12768. */
  12769. Control3D.prototype.getClassName = function () {
  12770. return this._getTypeName();
  12771. };
  12772. Control3D.prototype._getTypeName = function () {
  12773. return "Control3D";
  12774. };
  12775. Object.defineProperty(Control3D.prototype, "node", {
  12776. /**
  12777. * Gets the transform node used by this control
  12778. */
  12779. get: function () {
  12780. return this._node;
  12781. },
  12782. enumerable: true,
  12783. configurable: true
  12784. });
  12785. Object.defineProperty(Control3D.prototype, "mesh", {
  12786. /**
  12787. * Gets the mesh used to render this control
  12788. */
  12789. get: function () {
  12790. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12791. return this._node;
  12792. }
  12793. return null;
  12794. },
  12795. enumerable: true,
  12796. configurable: true
  12797. });
  12798. /**
  12799. * Link the control as child of the given node
  12800. * @param node defines the node to link to. Use null to unlink the control
  12801. * @returns the current control
  12802. */
  12803. Control3D.prototype.linkToTransformNode = function (node) {
  12804. if (this._node) {
  12805. this._node.parent = node;
  12806. }
  12807. return this;
  12808. };
  12809. /** @hidden **/
  12810. Control3D.prototype._prepareNode = function (scene) {
  12811. if (!this._node) {
  12812. this._node = this._createNode(scene);
  12813. if (!this.node) {
  12814. return;
  12815. }
  12816. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12817. this._node.position = this.position;
  12818. this._node.scaling = this.scaling;
  12819. var mesh = this.mesh;
  12820. if (mesh) {
  12821. mesh.isPickable = true;
  12822. this._affectMaterial(mesh);
  12823. }
  12824. }
  12825. };
  12826. /**
  12827. * Node creation.
  12828. * Can be overriden by children
  12829. * @param scene defines the scene where the node must be attached
  12830. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12831. */
  12832. Control3D.prototype._createNode = function (scene) {
  12833. // Do nothing by default
  12834. return null;
  12835. };
  12836. /**
  12837. * Affect a material to the given mesh
  12838. * @param mesh defines the mesh which will represent the control
  12839. */
  12840. Control3D.prototype._affectMaterial = function (mesh) {
  12841. mesh.material = null;
  12842. };
  12843. // Pointers
  12844. /** @hidden */
  12845. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12846. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12847. };
  12848. /** @hidden */
  12849. Control3D.prototype._onPointerEnter = function (target) {
  12850. if (this._enterCount > 0) {
  12851. return false;
  12852. }
  12853. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12854. this._enterCount = 0;
  12855. }
  12856. this._enterCount++;
  12857. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12858. if (this.pointerEnterAnimation) {
  12859. this.pointerEnterAnimation();
  12860. }
  12861. return true;
  12862. };
  12863. /** @hidden */
  12864. Control3D.prototype._onPointerOut = function (target) {
  12865. this._enterCount = 0;
  12866. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  12867. if (this.pointerOutAnimation) {
  12868. this.pointerOutAnimation();
  12869. }
  12870. };
  12871. /** @hidden */
  12872. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  12873. if (this._downCount !== 0) {
  12874. return false;
  12875. }
  12876. this._downCount++;
  12877. this._downPointerIds[pointerId] = true;
  12878. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12879. if (this.pointerDownAnimation) {
  12880. this.pointerDownAnimation();
  12881. }
  12882. return true;
  12883. };
  12884. /** @hidden */
  12885. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  12886. this._downCount = 0;
  12887. delete this._downPointerIds[pointerId];
  12888. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  12889. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12890. }
  12891. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12892. if (this.pointerUpAnimation) {
  12893. this.pointerUpAnimation();
  12894. }
  12895. };
  12896. /** @hidden */
  12897. Control3D.prototype.forcePointerUp = function (pointerId) {
  12898. if (pointerId === void 0) { pointerId = null; }
  12899. if (pointerId !== null) {
  12900. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  12901. }
  12902. else {
  12903. for (var key in this._downPointerIds) {
  12904. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  12905. }
  12906. }
  12907. };
  12908. /** @hidden */
  12909. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  12910. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  12911. this._onPointerMove(this, pickedPoint);
  12912. var previousControlOver = this._host._lastControlOver[pointerId];
  12913. if (previousControlOver && previousControlOver !== this) {
  12914. previousControlOver._onPointerOut(this);
  12915. }
  12916. if (previousControlOver !== this) {
  12917. this._onPointerEnter(this);
  12918. }
  12919. this._host._lastControlOver[pointerId] = this;
  12920. return true;
  12921. }
  12922. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  12923. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  12924. this._host._lastControlDown[pointerId] = this;
  12925. this._host._lastPickedControl = this;
  12926. return true;
  12927. }
  12928. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  12929. if (this._host._lastControlDown[pointerId]) {
  12930. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  12931. }
  12932. delete this._host._lastControlDown[pointerId];
  12933. return true;
  12934. }
  12935. return false;
  12936. };
  12937. /** @hidden */
  12938. Control3D.prototype._disposeNode = function () {
  12939. if (this._node) {
  12940. this._node.dispose();
  12941. this._node = null;
  12942. }
  12943. };
  12944. /**
  12945. * Releases all associated resources
  12946. */
  12947. Control3D.prototype.dispose = function () {
  12948. this.onPointerDownObservable.clear();
  12949. this.onPointerEnterObservable.clear();
  12950. this.onPointerMoveObservable.clear();
  12951. this.onPointerOutObservable.clear();
  12952. this.onPointerUpObservable.clear();
  12953. this.onPointerClickObservable.clear();
  12954. this._disposeNode();
  12955. // Behaviors
  12956. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12957. var behavior = _a[_i];
  12958. behavior.detach();
  12959. }
  12960. };
  12961. return Control3D;
  12962. }());
  12963. /***/ }),
  12964. /***/ "./3D/controls/cylinderPanel.ts":
  12965. /*!**************************************!*\
  12966. !*** ./3D/controls/cylinderPanel.ts ***!
  12967. \**************************************/
  12968. /*! exports provided: CylinderPanel */
  12969. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12970. "use strict";
  12971. __webpack_require__.r(__webpack_exports__);
  12972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  12973. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12974. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs");
  12975. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  12976. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  12977. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  12978. /**
  12979. * Class used to create a container panel deployed on the surface of a cylinder
  12980. */
  12981. var CylinderPanel = /** @class */ (function (_super) {
  12982. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  12983. function CylinderPanel() {
  12984. var _this = _super !== null && _super.apply(this, arguments) || this;
  12985. _this._radius = 5.0;
  12986. return _this;
  12987. }
  12988. Object.defineProperty(CylinderPanel.prototype, "radius", {
  12989. /**
  12990. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  12991. */
  12992. get: function () {
  12993. return this._radius;
  12994. },
  12995. set: function (value) {
  12996. var _this = this;
  12997. if (this._radius === value) {
  12998. return;
  12999. }
  13000. this._radius = value;
  13001. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13002. _this._arrangeChildren();
  13003. });
  13004. },
  13005. enumerable: true,
  13006. configurable: true
  13007. });
  13008. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13009. var mesh = control.mesh;
  13010. if (!mesh) {
  13011. return;
  13012. }
  13013. var newPos = this._cylindricalMapping(nodePosition);
  13014. control.position = newPos;
  13015. switch (this.orientation) {
  13016. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13017. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13018. break;
  13019. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13020. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13021. break;
  13022. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13023. break;
  13024. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13025. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13026. break;
  13027. }
  13028. };
  13029. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13030. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13031. var yAngle = (source.x / this._radius);
  13032. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13033. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13034. };
  13035. return CylinderPanel;
  13036. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13037. /***/ }),
  13038. /***/ "./3D/controls/holographicButton.ts":
  13039. /*!******************************************!*\
  13040. !*** ./3D/controls/holographicButton.ts ***!
  13041. \******************************************/
  13042. /*! exports provided: HolographicButton */
  13043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13044. "use strict";
  13045. __webpack_require__.r(__webpack_exports__);
  13046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13047. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13048. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13049. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs");
  13050. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13051. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13052. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13053. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13054. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13055. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13056. /**
  13057. * Class used to create a holographic button in 3D
  13058. */
  13059. var HolographicButton = /** @class */ (function (_super) {
  13060. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13061. /**
  13062. * Creates a new button
  13063. * @param name defines the control name
  13064. */
  13065. function HolographicButton(name, shareMaterials) {
  13066. if (shareMaterials === void 0) { shareMaterials = true; }
  13067. var _this = _super.call(this, name) || this;
  13068. _this._shareMaterials = true;
  13069. _this._shareMaterials = shareMaterials;
  13070. // Default animations
  13071. _this.pointerEnterAnimation = function () {
  13072. if (!_this.mesh) {
  13073. return;
  13074. }
  13075. _this._frontPlate.setEnabled(true);
  13076. };
  13077. _this.pointerOutAnimation = function () {
  13078. if (!_this.mesh) {
  13079. return;
  13080. }
  13081. _this._frontPlate.setEnabled(false);
  13082. };
  13083. return _this;
  13084. }
  13085. HolographicButton.prototype._disposeTooltip = function () {
  13086. this._tooltipFade = null;
  13087. if (this._tooltipTextBlock) {
  13088. this._tooltipTextBlock.dispose();
  13089. }
  13090. if (this._tooltipTexture) {
  13091. this._tooltipTexture.dispose();
  13092. }
  13093. if (this._tooltipMesh) {
  13094. this._tooltipMesh.dispose();
  13095. }
  13096. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13097. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13098. };
  13099. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13100. get: function () {
  13101. if (this._tooltipTextBlock) {
  13102. return this._tooltipTextBlock.text;
  13103. }
  13104. return null;
  13105. },
  13106. /**
  13107. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13108. */
  13109. set: function (text) {
  13110. var _this = this;
  13111. if (!text) {
  13112. this._disposeTooltip();
  13113. return;
  13114. }
  13115. if (!this._tooltipFade) {
  13116. // Create tooltip with mesh and text
  13117. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13118. 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);
  13119. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13120. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13121. tooltipBackground.material = mat;
  13122. tooltipBackground.isPickable = false;
  13123. this._tooltipMesh.addChild(tooltipBackground);
  13124. tooltipBackground.position.z = 0.05;
  13125. this._tooltipMesh.scaling.y = 1 / 3;
  13126. this._tooltipMesh.position.y = 0.7;
  13127. this._tooltipMesh.position.z = -0.15;
  13128. this._tooltipMesh.isPickable = false;
  13129. this._tooltipMesh.parent = this._backPlate;
  13130. // Create text texture for the tooltip
  13131. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13132. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13133. this._tooltipTextBlock.scaleY = 3;
  13134. this._tooltipTextBlock.color = "white";
  13135. this._tooltipTextBlock.fontSize = 130;
  13136. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13137. // Add hover action to tooltip
  13138. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13139. this._tooltipFade.delay = 500;
  13140. this._tooltipMesh.addBehavior(this._tooltipFade);
  13141. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13142. if (_this._tooltipFade) {
  13143. _this._tooltipFade.fadeIn(true);
  13144. }
  13145. });
  13146. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13147. if (_this._tooltipFade) {
  13148. _this._tooltipFade.fadeIn(false);
  13149. }
  13150. });
  13151. }
  13152. if (this._tooltipTextBlock) {
  13153. this._tooltipTextBlock.text = text;
  13154. }
  13155. },
  13156. enumerable: true,
  13157. configurable: true
  13158. });
  13159. Object.defineProperty(HolographicButton.prototype, "text", {
  13160. /**
  13161. * Gets or sets text for the button
  13162. */
  13163. get: function () {
  13164. return this._text;
  13165. },
  13166. set: function (value) {
  13167. if (this._text === value) {
  13168. return;
  13169. }
  13170. this._text = value;
  13171. this._rebuildContent();
  13172. },
  13173. enumerable: true,
  13174. configurable: true
  13175. });
  13176. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13177. /**
  13178. * Gets or sets the image url for the button
  13179. */
  13180. get: function () {
  13181. return this._imageUrl;
  13182. },
  13183. set: function (value) {
  13184. if (this._imageUrl === value) {
  13185. return;
  13186. }
  13187. this._imageUrl = value;
  13188. this._rebuildContent();
  13189. },
  13190. enumerable: true,
  13191. configurable: true
  13192. });
  13193. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13194. /**
  13195. * Gets the back material used by this button
  13196. */
  13197. get: function () {
  13198. return this._backMaterial;
  13199. },
  13200. enumerable: true,
  13201. configurable: true
  13202. });
  13203. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13204. /**
  13205. * Gets the front material used by this button
  13206. */
  13207. get: function () {
  13208. return this._frontMaterial;
  13209. },
  13210. enumerable: true,
  13211. configurable: true
  13212. });
  13213. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13214. /**
  13215. * Gets the plate material used by this button
  13216. */
  13217. get: function () {
  13218. return this._plateMaterial;
  13219. },
  13220. enumerable: true,
  13221. configurable: true
  13222. });
  13223. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13224. /**
  13225. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13226. */
  13227. get: function () {
  13228. return this._shareMaterials;
  13229. },
  13230. enumerable: true,
  13231. configurable: true
  13232. });
  13233. HolographicButton.prototype._getTypeName = function () {
  13234. return "HolographicButton";
  13235. };
  13236. HolographicButton.prototype._rebuildContent = function () {
  13237. this._disposeFacadeTexture();
  13238. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13239. panel.isVertical = true;
  13240. if (this._imageUrl) {
  13241. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13242. image.source = this._imageUrl;
  13243. image.paddingTop = "40px";
  13244. image.height = "180px";
  13245. image.width = "100px";
  13246. image.paddingBottom = "40px";
  13247. panel.addControl(image);
  13248. }
  13249. if (this._text) {
  13250. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13251. text.text = this._text;
  13252. text.color = "white";
  13253. text.height = "30px";
  13254. text.fontSize = 24;
  13255. panel.addControl(text);
  13256. }
  13257. if (this._frontPlate) {
  13258. this.content = panel;
  13259. }
  13260. };
  13261. // Mesh association
  13262. HolographicButton.prototype._createNode = function (scene) {
  13263. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13264. width: 1.0,
  13265. height: 1.0,
  13266. depth: 0.08
  13267. }, scene);
  13268. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13269. width: 1.0,
  13270. height: 1.0,
  13271. depth: 0.08
  13272. }, scene);
  13273. this._frontPlate.parent = this._backPlate;
  13274. this._frontPlate.position.z = -0.08;
  13275. this._frontPlate.isPickable = false;
  13276. this._frontPlate.setEnabled(false);
  13277. this._textPlate = _super.prototype._createNode.call(this, scene);
  13278. this._textPlate.parent = this._backPlate;
  13279. this._textPlate.position.z = -0.08;
  13280. this._textPlate.isPickable = false;
  13281. return this._backPlate;
  13282. };
  13283. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13284. this._plateMaterial.emissiveTexture = facadeTexture;
  13285. this._plateMaterial.opacityTexture = facadeTexture;
  13286. };
  13287. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13288. var _this = this;
  13289. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13290. this._backMaterial.renderHoverLight = true;
  13291. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13292. if (pickedPoint) {
  13293. _this._backMaterial.hoverPosition = pickedPoint;
  13294. _this._backMaterial.hoverColor.a = 1.0;
  13295. }
  13296. else {
  13297. _this._backMaterial.hoverColor.a = 0;
  13298. }
  13299. });
  13300. };
  13301. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13302. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13303. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13304. this._frontMaterial.alpha = 0.5; // Additive
  13305. this._frontMaterial.renderBorders = true;
  13306. };
  13307. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13308. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13309. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13310. };
  13311. HolographicButton.prototype._affectMaterial = function (mesh) {
  13312. // Back
  13313. if (this._shareMaterials) {
  13314. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13315. this._createBackMaterial(mesh);
  13316. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13317. }
  13318. else {
  13319. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13320. }
  13321. // Front
  13322. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13323. this._createFrontMaterial(mesh);
  13324. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13325. }
  13326. else {
  13327. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13328. }
  13329. }
  13330. else {
  13331. this._createBackMaterial(mesh);
  13332. this._createFrontMaterial(mesh);
  13333. }
  13334. this._createPlateMaterial(mesh);
  13335. this._backPlate.material = this._backMaterial;
  13336. this._frontPlate.material = this._frontMaterial;
  13337. this._textPlate.material = this._plateMaterial;
  13338. this._rebuildContent();
  13339. };
  13340. /**
  13341. * Releases all associated resources
  13342. */
  13343. HolographicButton.prototype.dispose = function () {
  13344. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13345. this._disposeTooltip();
  13346. if (!this.shareMaterials) {
  13347. this._backMaterial.dispose();
  13348. this._frontMaterial.dispose();
  13349. this._plateMaterial.dispose();
  13350. if (this._pickedPointObserver) {
  13351. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13352. this._pickedPointObserver = null;
  13353. }
  13354. }
  13355. };
  13356. return HolographicButton;
  13357. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13358. /***/ }),
  13359. /***/ "./3D/controls/index.ts":
  13360. /*!******************************!*\
  13361. !*** ./3D/controls/index.ts ***!
  13362. \******************************/
  13363. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13364. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13365. "use strict";
  13366. __webpack_require__.r(__webpack_exports__);
  13367. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13369. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13371. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13373. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13375. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13377. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13379. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13381. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13383. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13385. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13387. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13389. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13391. /***/ }),
  13392. /***/ "./3D/controls/meshButton3D.ts":
  13393. /*!*************************************!*\
  13394. !*** ./3D/controls/meshButton3D.ts ***!
  13395. \*************************************/
  13396. /*! exports provided: MeshButton3D */
  13397. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13398. "use strict";
  13399. __webpack_require__.r(__webpack_exports__);
  13400. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13401. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13402. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13403. /**
  13404. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13405. */
  13406. var MeshButton3D = /** @class */ (function (_super) {
  13407. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13408. /**
  13409. * Creates a new 3D button based on a mesh
  13410. * @param mesh mesh to become a 3D button
  13411. * @param name defines the control name
  13412. */
  13413. function MeshButton3D(mesh, name) {
  13414. var _this = _super.call(this, name) || this;
  13415. _this._currentMesh = mesh;
  13416. /**
  13417. * Provides a default behavior on hover/out & up/down
  13418. * Override those function to create your own desired behavior specific to your mesh
  13419. */
  13420. _this.pointerEnterAnimation = function () {
  13421. if (!_this.mesh) {
  13422. return;
  13423. }
  13424. _this.mesh.scaling.scaleInPlace(1.1);
  13425. };
  13426. _this.pointerOutAnimation = function () {
  13427. if (!_this.mesh) {
  13428. return;
  13429. }
  13430. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13431. };
  13432. _this.pointerDownAnimation = function () {
  13433. if (!_this.mesh) {
  13434. return;
  13435. }
  13436. _this.mesh.scaling.scaleInPlace(0.95);
  13437. };
  13438. _this.pointerUpAnimation = function () {
  13439. if (!_this.mesh) {
  13440. return;
  13441. }
  13442. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13443. };
  13444. return _this;
  13445. }
  13446. MeshButton3D.prototype._getTypeName = function () {
  13447. return "MeshButton3D";
  13448. };
  13449. // Mesh association
  13450. MeshButton3D.prototype._createNode = function (scene) {
  13451. var _this = this;
  13452. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13453. mesh.metadata = _this;
  13454. });
  13455. return this._currentMesh;
  13456. };
  13457. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13458. };
  13459. return MeshButton3D;
  13460. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13461. /***/ }),
  13462. /***/ "./3D/controls/planePanel.ts":
  13463. /*!***********************************!*\
  13464. !*** ./3D/controls/planePanel.ts ***!
  13465. \***********************************/
  13466. /*! exports provided: PlanePanel */
  13467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13468. "use strict";
  13469. __webpack_require__.r(__webpack_exports__);
  13470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13471. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13472. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs");
  13473. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13474. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13475. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13476. /**
  13477. * Class used to create a container panel deployed on the surface of a plane
  13478. */
  13479. var PlanePanel = /** @class */ (function (_super) {
  13480. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13481. function PlanePanel() {
  13482. return _super !== null && _super.apply(this, arguments) || this;
  13483. }
  13484. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13485. var mesh = control.mesh;
  13486. if (!mesh) {
  13487. return;
  13488. }
  13489. control.position = nodePosition.clone();
  13490. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13491. target.copyFrom(nodePosition);
  13492. switch (this.orientation) {
  13493. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13494. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13495. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13496. mesh.lookAt(target);
  13497. break;
  13498. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13499. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13500. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13501. mesh.lookAt(target);
  13502. break;
  13503. }
  13504. };
  13505. return PlanePanel;
  13506. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13507. /***/ }),
  13508. /***/ "./3D/controls/scatterPanel.ts":
  13509. /*!*************************************!*\
  13510. !*** ./3D/controls/scatterPanel.ts ***!
  13511. \*************************************/
  13512. /*! exports provided: ScatterPanel */
  13513. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13514. "use strict";
  13515. __webpack_require__.r(__webpack_exports__);
  13516. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13517. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13518. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs");
  13519. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13520. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13521. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13522. /**
  13523. * Class used to create a container panel where items get randomized planar mapping
  13524. */
  13525. var ScatterPanel = /** @class */ (function (_super) {
  13526. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13527. function ScatterPanel() {
  13528. var _this = _super !== null && _super.apply(this, arguments) || this;
  13529. _this._iteration = 100.0;
  13530. return _this;
  13531. }
  13532. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13533. /**
  13534. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13535. */
  13536. get: function () {
  13537. return this._iteration;
  13538. },
  13539. set: function (value) {
  13540. var _this = this;
  13541. if (this._iteration === value) {
  13542. return;
  13543. }
  13544. this._iteration = value;
  13545. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13546. _this._arrangeChildren();
  13547. });
  13548. },
  13549. enumerable: true,
  13550. configurable: true
  13551. });
  13552. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13553. var mesh = control.mesh;
  13554. var newPos = this._scatterMapping(nodePosition);
  13555. if (!mesh) {
  13556. return;
  13557. }
  13558. switch (this.orientation) {
  13559. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13560. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13561. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13562. break;
  13563. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13564. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13565. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13566. break;
  13567. }
  13568. control.position = newPos;
  13569. };
  13570. ScatterPanel.prototype._scatterMapping = function (source) {
  13571. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13572. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13573. return source;
  13574. };
  13575. ScatterPanel.prototype._finalProcessing = function () {
  13576. var meshes = [];
  13577. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13578. var child = _a[_i];
  13579. if (!child.mesh) {
  13580. continue;
  13581. }
  13582. meshes.push(child.mesh);
  13583. }
  13584. for (var count = 0; count < this._iteration; count++) {
  13585. meshes.sort(function (a, b) {
  13586. var distance1 = a.position.lengthSquared();
  13587. var distance2 = b.position.lengthSquared();
  13588. if (distance1 < distance2) {
  13589. return 1;
  13590. }
  13591. else if (distance1 > distance2) {
  13592. return -1;
  13593. }
  13594. return 0;
  13595. });
  13596. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13597. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13598. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector2[0];
  13599. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13600. for (var i = 0; i < meshes.length - 1; i++) {
  13601. for (var j = i + 1; j < meshes.length; j++) {
  13602. if (i != j) {
  13603. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13604. // Ignore Z axis
  13605. difference2D.x = difference.x;
  13606. difference2D.y = difference.y;
  13607. var combinedRadius = cellSize;
  13608. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13609. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13610. distance -= minSeparation;
  13611. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13612. difference2D.normalize();
  13613. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13614. meshes[j].position.addInPlace(difference);
  13615. meshes[i].position.subtractInPlace(difference);
  13616. }
  13617. }
  13618. }
  13619. }
  13620. }
  13621. };
  13622. return ScatterPanel;
  13623. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13624. /***/ }),
  13625. /***/ "./3D/controls/spherePanel.ts":
  13626. /*!************************************!*\
  13627. !*** ./3D/controls/spherePanel.ts ***!
  13628. \************************************/
  13629. /*! exports provided: SpherePanel */
  13630. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13631. "use strict";
  13632. __webpack_require__.r(__webpack_exports__);
  13633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13634. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13635. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs");
  13636. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13637. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13638. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13639. /**
  13640. * Class used to create a container panel deployed on the surface of a sphere
  13641. */
  13642. var SpherePanel = /** @class */ (function (_super) {
  13643. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13644. function SpherePanel() {
  13645. var _this = _super !== null && _super.apply(this, arguments) || this;
  13646. _this._radius = 5.0;
  13647. return _this;
  13648. }
  13649. Object.defineProperty(SpherePanel.prototype, "radius", {
  13650. /**
  13651. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13652. */
  13653. get: function () {
  13654. return this._radius;
  13655. },
  13656. set: function (value) {
  13657. var _this = this;
  13658. if (this._radius === value) {
  13659. return;
  13660. }
  13661. this._radius = value;
  13662. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13663. _this._arrangeChildren();
  13664. });
  13665. },
  13666. enumerable: true,
  13667. configurable: true
  13668. });
  13669. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13670. var mesh = control.mesh;
  13671. if (!mesh) {
  13672. return;
  13673. }
  13674. var newPos = this._sphericalMapping(nodePosition);
  13675. control.position = newPos;
  13676. switch (this.orientation) {
  13677. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13678. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13679. break;
  13680. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13681. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13682. break;
  13683. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13684. break;
  13685. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13686. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13687. break;
  13688. }
  13689. };
  13690. SpherePanel.prototype._sphericalMapping = function (source) {
  13691. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13692. var xAngle = (source.y / this._radius);
  13693. var yAngle = -(source.x / this._radius);
  13694. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13695. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13696. };
  13697. return SpherePanel;
  13698. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13699. /***/ }),
  13700. /***/ "./3D/controls/stackPanel3D.ts":
  13701. /*!*************************************!*\
  13702. !*** ./3D/controls/stackPanel3D.ts ***!
  13703. \*************************************/
  13704. /*! exports provided: StackPanel3D */
  13705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13706. "use strict";
  13707. __webpack_require__.r(__webpack_exports__);
  13708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13709. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13710. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs");
  13711. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13712. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13713. /**
  13714. * Class used to create a stack panel in 3D on XY plane
  13715. */
  13716. var StackPanel3D = /** @class */ (function (_super) {
  13717. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13718. /**
  13719. * Creates new StackPanel
  13720. * @param isVertical
  13721. */
  13722. function StackPanel3D(isVertical) {
  13723. if (isVertical === void 0) { isVertical = false; }
  13724. var _this = _super.call(this) || this;
  13725. _this._isVertical = false;
  13726. /**
  13727. * Gets or sets the distance between elements
  13728. */
  13729. _this.margin = 0.1;
  13730. _this._isVertical = isVertical;
  13731. return _this;
  13732. }
  13733. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13734. /**
  13735. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13736. */
  13737. get: function () {
  13738. return this._isVertical;
  13739. },
  13740. set: function (value) {
  13741. var _this = this;
  13742. if (this._isVertical === value) {
  13743. return;
  13744. }
  13745. this._isVertical = value;
  13746. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13747. _this._arrangeChildren();
  13748. });
  13749. },
  13750. enumerable: true,
  13751. configurable: true
  13752. });
  13753. StackPanel3D.prototype._arrangeChildren = function () {
  13754. var width = 0;
  13755. var height = 0;
  13756. var controlCount = 0;
  13757. var extendSizes = [];
  13758. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13759. // Measure
  13760. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13761. var child = _a[_i];
  13762. if (!child.mesh) {
  13763. continue;
  13764. }
  13765. controlCount++;
  13766. child.mesh.computeWorldMatrix(true);
  13767. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13768. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13769. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13770. extendSizes.push(extendSize);
  13771. if (this._isVertical) {
  13772. height += extendSize.y;
  13773. }
  13774. else {
  13775. width += extendSize.x;
  13776. }
  13777. }
  13778. if (this._isVertical) {
  13779. height += (controlCount - 1) * this.margin / 2;
  13780. }
  13781. else {
  13782. width += (controlCount - 1) * this.margin / 2;
  13783. }
  13784. // Arrange
  13785. var offset;
  13786. if (this._isVertical) {
  13787. offset = -height;
  13788. }
  13789. else {
  13790. offset = -width;
  13791. }
  13792. var index = 0;
  13793. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13794. var child = _c[_b];
  13795. if (!child.mesh) {
  13796. continue;
  13797. }
  13798. controlCount--;
  13799. var extendSize = extendSizes[index++];
  13800. if (this._isVertical) {
  13801. child.position.y = offset + extendSize.y;
  13802. child.position.x = 0;
  13803. offset += extendSize.y * 2;
  13804. }
  13805. else {
  13806. child.position.x = offset + extendSize.x;
  13807. child.position.y = 0;
  13808. offset += extendSize.x * 2;
  13809. }
  13810. offset += (controlCount > 0 ? this.margin : 0);
  13811. }
  13812. };
  13813. return StackPanel3D;
  13814. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13815. /***/ }),
  13816. /***/ "./3D/controls/volumeBasedPanel.ts":
  13817. /*!*****************************************!*\
  13818. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13819. \*****************************************/
  13820. /*! exports provided: VolumeBasedPanel */
  13821. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13822. "use strict";
  13823. __webpack_require__.r(__webpack_exports__);
  13824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13825. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13826. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs");
  13827. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13828. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13829. /**
  13830. * Abstract class used to create a container panel deployed on the surface of a volume
  13831. */
  13832. var VolumeBasedPanel = /** @class */ (function (_super) {
  13833. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13834. /**
  13835. * Creates new VolumeBasedPanel
  13836. */
  13837. function VolumeBasedPanel() {
  13838. var _this = _super.call(this) || this;
  13839. _this._columns = 10;
  13840. _this._rows = 0;
  13841. _this._rowThenColum = true;
  13842. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13843. /**
  13844. * Gets or sets the distance between elements
  13845. */
  13846. _this.margin = 0;
  13847. return _this;
  13848. }
  13849. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13850. /**
  13851. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13852. * | Value | Type | Description |
  13853. * | ----- | ----------------------------------- | ----------- |
  13854. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  13855. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  13856. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  13857. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  13858. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  13859. */
  13860. get: function () {
  13861. return this._orientation;
  13862. },
  13863. set: function (value) {
  13864. var _this = this;
  13865. if (this._orientation === value) {
  13866. return;
  13867. }
  13868. this._orientation = value;
  13869. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13870. _this._arrangeChildren();
  13871. });
  13872. },
  13873. enumerable: true,
  13874. configurable: true
  13875. });
  13876. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  13877. /**
  13878. * Gets or sets the number of columns requested (10 by default).
  13879. * The panel will automatically compute the number of rows based on number of child controls.
  13880. */
  13881. get: function () {
  13882. return this._columns;
  13883. },
  13884. set: function (value) {
  13885. var _this = this;
  13886. if (this._columns === value) {
  13887. return;
  13888. }
  13889. this._columns = value;
  13890. this._rowThenColum = true;
  13891. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13892. _this._arrangeChildren();
  13893. });
  13894. },
  13895. enumerable: true,
  13896. configurable: true
  13897. });
  13898. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  13899. /**
  13900. * Gets or sets a the number of rows requested.
  13901. * The panel will automatically compute the number of columns based on number of child controls.
  13902. */
  13903. get: function () {
  13904. return this._rows;
  13905. },
  13906. set: function (value) {
  13907. var _this = this;
  13908. if (this._rows === value) {
  13909. return;
  13910. }
  13911. this._rows = value;
  13912. this._rowThenColum = false;
  13913. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13914. _this._arrangeChildren();
  13915. });
  13916. },
  13917. enumerable: true,
  13918. configurable: true
  13919. });
  13920. VolumeBasedPanel.prototype._arrangeChildren = function () {
  13921. this._cellWidth = 0;
  13922. this._cellHeight = 0;
  13923. var rows = 0;
  13924. var columns = 0;
  13925. var controlCount = 0;
  13926. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13927. // Measure
  13928. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13929. var child = _a[_i];
  13930. if (!child.mesh) {
  13931. continue;
  13932. }
  13933. controlCount++;
  13934. child.mesh.computeWorldMatrix(true);
  13935. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  13936. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  13937. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13938. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  13939. boundingBox.max.subtractToRef(boundingBox.min, diff);
  13940. diff.scaleInPlace(0.5);
  13941. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  13942. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  13943. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  13944. }
  13945. this._cellWidth += this.margin * 2;
  13946. this._cellHeight += this.margin * 2;
  13947. // Arrange
  13948. if (this._rowThenColum) {
  13949. columns = this._columns;
  13950. rows = Math.ceil(controlCount / this._columns);
  13951. }
  13952. else {
  13953. rows = this._rows;
  13954. columns = Math.ceil(controlCount / this._rows);
  13955. }
  13956. var startOffsetX = (columns * 0.5) * this._cellWidth;
  13957. var startOffsetY = (rows * 0.5) * this._cellHeight;
  13958. var nodeGrid = [];
  13959. var cellCounter = 0;
  13960. if (this._rowThenColum) {
  13961. for (var r = 0; r < rows; r++) {
  13962. for (var c = 0; c < columns; c++) {
  13963. 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));
  13964. cellCounter++;
  13965. if (cellCounter > controlCount) {
  13966. break;
  13967. }
  13968. }
  13969. }
  13970. }
  13971. else {
  13972. for (var c = 0; c < columns; c++) {
  13973. for (var r = 0; r < rows; r++) {
  13974. 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));
  13975. cellCounter++;
  13976. if (cellCounter > controlCount) {
  13977. break;
  13978. }
  13979. }
  13980. }
  13981. }
  13982. cellCounter = 0;
  13983. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13984. var child = _c[_b];
  13985. if (!child.mesh) {
  13986. continue;
  13987. }
  13988. this._mapGridNode(child, nodeGrid[cellCounter]);
  13989. cellCounter++;
  13990. }
  13991. this._finalProcessing();
  13992. };
  13993. /** Child classes can implement this function to provide additional processing */
  13994. VolumeBasedPanel.prototype._finalProcessing = function () {
  13995. };
  13996. return VolumeBasedPanel;
  13997. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13998. /***/ }),
  13999. /***/ "./3D/gui3DManager.ts":
  14000. /*!****************************!*\
  14001. !*** ./3D/gui3DManager.ts ***!
  14002. \****************************/
  14003. /*! exports provided: GUI3DManager */
  14004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14005. "use strict";
  14006. __webpack_require__.r(__webpack_exports__);
  14007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14008. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs");
  14009. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14010. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14011. /**
  14012. * Class used to manage 3D user interface
  14013. * @see http://doc.babylonjs.com/how_to/gui3d
  14014. */
  14015. var GUI3DManager = /** @class */ (function () {
  14016. /**
  14017. * Creates a new GUI3DManager
  14018. * @param scene
  14019. */
  14020. function GUI3DManager(scene) {
  14021. var _this = this;
  14022. /** @hidden */
  14023. this._lastControlOver = {};
  14024. /** @hidden */
  14025. this._lastControlDown = {};
  14026. /**
  14027. * Observable raised when the point picked by the pointer events changed
  14028. */
  14029. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14030. // Shared resources
  14031. /** @hidden */
  14032. this._sharedMaterials = {};
  14033. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14034. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14035. _this._sceneDisposeObserver = null;
  14036. _this._utilityLayer = null;
  14037. _this.dispose();
  14038. });
  14039. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14040. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14041. this._utilityLayer.pickUtilitySceneFirst = false;
  14042. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14043. return mesh && mesh.metadata && mesh.metadata._node;
  14044. };
  14045. // Root
  14046. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14047. this._rootContainer._host = this;
  14048. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14049. // Events
  14050. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14051. _this._handlePointerOut(pointerId, true);
  14052. });
  14053. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14054. _this._doPicking(pi);
  14055. });
  14056. // Scene
  14057. this._utilityLayer.utilityLayerScene.autoClear = false;
  14058. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14059. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14060. }
  14061. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14062. /** Gets the hosting scene */
  14063. get: function () {
  14064. return this._scene;
  14065. },
  14066. enumerable: true,
  14067. configurable: true
  14068. });
  14069. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14070. /** Gets associated utility layer */
  14071. get: function () {
  14072. return this._utilityLayer;
  14073. },
  14074. enumerable: true,
  14075. configurable: true
  14076. });
  14077. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14078. var previousControlOver = this._lastControlOver[pointerId];
  14079. if (previousControlOver) {
  14080. previousControlOver._onPointerOut(previousControlOver);
  14081. delete this._lastControlOver[pointerId];
  14082. }
  14083. if (isPointerUp) {
  14084. if (this._lastControlDown[pointerId]) {
  14085. this._lastControlDown[pointerId].forcePointerUp();
  14086. delete this._lastControlDown[pointerId];
  14087. }
  14088. }
  14089. this.onPickedPointChangedObservable.notifyObservers(null);
  14090. };
  14091. GUI3DManager.prototype._doPicking = function (pi) {
  14092. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14093. return false;
  14094. }
  14095. var pointerEvent = (pi.event);
  14096. var pointerId = pointerEvent.pointerId || 0;
  14097. var buttonIndex = pointerEvent.button;
  14098. var pickingInfo = pi.pickInfo;
  14099. if (!pickingInfo || !pickingInfo.hit) {
  14100. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14101. return false;
  14102. }
  14103. var control = (pickingInfo.pickedMesh.metadata);
  14104. if (pickingInfo.pickedPoint) {
  14105. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14106. }
  14107. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14108. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14109. if (this._lastControlOver[pointerId]) {
  14110. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14111. }
  14112. delete this._lastControlOver[pointerId];
  14113. }
  14114. }
  14115. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14116. if (this._lastControlDown[pointerEvent.pointerId]) {
  14117. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14118. delete this._lastControlDown[pointerEvent.pointerId];
  14119. }
  14120. if (pointerEvent.pointerType === "touch") {
  14121. this._handlePointerOut(pointerId, false);
  14122. }
  14123. }
  14124. return true;
  14125. };
  14126. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14127. /**
  14128. * Gets the root container
  14129. */
  14130. get: function () {
  14131. return this._rootContainer;
  14132. },
  14133. enumerable: true,
  14134. configurable: true
  14135. });
  14136. /**
  14137. * Gets a boolean indicating if the given control is in the root child list
  14138. * @param control defines the control to check
  14139. * @returns true if the control is in the root child list
  14140. */
  14141. GUI3DManager.prototype.containsControl = function (control) {
  14142. return this._rootContainer.containsControl(control);
  14143. };
  14144. /**
  14145. * Adds a control to the root child list
  14146. * @param control defines the control to add
  14147. * @returns the current manager
  14148. */
  14149. GUI3DManager.prototype.addControl = function (control) {
  14150. this._rootContainer.addControl(control);
  14151. return this;
  14152. };
  14153. /**
  14154. * Removes a control from the root child list
  14155. * @param control defines the control to remove
  14156. * @returns the current container
  14157. */
  14158. GUI3DManager.prototype.removeControl = function (control) {
  14159. this._rootContainer.removeControl(control);
  14160. return this;
  14161. };
  14162. /**
  14163. * Releases all associated resources
  14164. */
  14165. GUI3DManager.prototype.dispose = function () {
  14166. this._rootContainer.dispose();
  14167. for (var materialName in this._sharedMaterials) {
  14168. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14169. continue;
  14170. }
  14171. this._sharedMaterials[materialName].dispose();
  14172. }
  14173. this._sharedMaterials = {};
  14174. if (this._pointerOutObserver && this._utilityLayer) {
  14175. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14176. this._pointerOutObserver = null;
  14177. }
  14178. this.onPickedPointChangedObservable.clear();
  14179. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14180. if (utilityLayerScene) {
  14181. if (this._pointerObserver) {
  14182. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14183. this._pointerObserver = null;
  14184. }
  14185. }
  14186. if (this._scene) {
  14187. if (this._sceneDisposeObserver) {
  14188. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14189. this._sceneDisposeObserver = null;
  14190. }
  14191. }
  14192. if (this._utilityLayer) {
  14193. this._utilityLayer.dispose();
  14194. }
  14195. };
  14196. return GUI3DManager;
  14197. }());
  14198. /***/ }),
  14199. /***/ "./3D/index.ts":
  14200. /*!*********************!*\
  14201. !*** ./3D/index.ts ***!
  14202. \*********************/
  14203. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14204. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14205. "use strict";
  14206. __webpack_require__.r(__webpack_exports__);
  14207. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14220. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14223. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14225. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14227. /***/ }),
  14228. /***/ "./3D/materials/fluentMaterial.ts":
  14229. /*!****************************************!*\
  14230. !*** ./3D/materials/fluentMaterial.ts ***!
  14231. \****************************************/
  14232. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14234. "use strict";
  14235. __webpack_require__.r(__webpack_exports__);
  14236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14238. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14239. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs");
  14240. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14241. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14242. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14243. /** @hidden */
  14244. var FluentMaterialDefines = /** @class */ (function (_super) {
  14245. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14246. function FluentMaterialDefines() {
  14247. var _this = _super.call(this) || this;
  14248. _this.INNERGLOW = false;
  14249. _this.BORDER = false;
  14250. _this.HOVERLIGHT = false;
  14251. _this.TEXTURE = false;
  14252. _this.rebuild();
  14253. return _this;
  14254. }
  14255. return FluentMaterialDefines;
  14256. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14257. /**
  14258. * Class used to render controls with fluent desgin
  14259. */
  14260. var FluentMaterial = /** @class */ (function (_super) {
  14261. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14262. /**
  14263. * Creates a new Fluent material
  14264. * @param name defines the name of the material
  14265. * @param scene defines the hosting scene
  14266. */
  14267. function FluentMaterial(name, scene) {
  14268. var _this = _super.call(this, name, scene) || this;
  14269. /**
  14270. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14271. */
  14272. _this.innerGlowColorIntensity = 0.5;
  14273. /**
  14274. * Gets or sets the inner glow color (white by default)
  14275. */
  14276. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14277. /**
  14278. * Gets or sets alpha value (default is 1.0)
  14279. */
  14280. _this.alpha = 1.0;
  14281. /**
  14282. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14283. */
  14284. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14285. /**
  14286. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14287. */
  14288. _this.renderBorders = false;
  14289. /**
  14290. * Gets or sets border width (default is 0.5)
  14291. */
  14292. _this.borderWidth = 0.5;
  14293. /**
  14294. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14295. */
  14296. _this.edgeSmoothingValue = 0.02;
  14297. /**
  14298. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14299. */
  14300. _this.borderMinValue = 0.1;
  14301. /**
  14302. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14303. */
  14304. _this.renderHoverLight = false;
  14305. /**
  14306. * Gets or sets the radius used to render the hover light (default is 1.0)
  14307. */
  14308. _this.hoverRadius = 1.0;
  14309. /**
  14310. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14311. */
  14312. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14313. /**
  14314. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14315. */
  14316. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14317. return _this;
  14318. }
  14319. FluentMaterial.prototype.needAlphaBlending = function () {
  14320. return this.alpha !== 1.0;
  14321. };
  14322. FluentMaterial.prototype.needAlphaTesting = function () {
  14323. return false;
  14324. };
  14325. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14326. return null;
  14327. };
  14328. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14329. if (this.isFrozen) {
  14330. if (this._wasPreviouslyReady && subMesh.effect) {
  14331. return true;
  14332. }
  14333. }
  14334. if (!subMesh._materialDefines) {
  14335. subMesh._materialDefines = new FluentMaterialDefines();
  14336. }
  14337. var scene = this.getScene();
  14338. var defines = subMesh._materialDefines;
  14339. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14340. if (defines._renderId === scene.getRenderId()) {
  14341. return true;
  14342. }
  14343. }
  14344. if (defines._areTexturesDirty) {
  14345. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14346. defines.BORDER = this.renderBorders;
  14347. defines.HOVERLIGHT = this.renderHoverLight;
  14348. if (this._albedoTexture) {
  14349. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14350. return false;
  14351. }
  14352. else {
  14353. defines.TEXTURE = true;
  14354. }
  14355. }
  14356. else {
  14357. defines.TEXTURE = false;
  14358. }
  14359. }
  14360. var engine = scene.getEngine();
  14361. // Get correct effect
  14362. if (defines.isDirty) {
  14363. defines.markAsProcessed();
  14364. scene.resetCachedMaterial();
  14365. //Attributes
  14366. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14367. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14368. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14369. var shaderName = "fluent";
  14370. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14371. "hoverColor", "hoverPosition", "hoverRadius"
  14372. ];
  14373. var samplers = ["albedoSampler"];
  14374. var uniformBuffers = new Array();
  14375. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14376. uniformsNames: uniforms,
  14377. uniformBuffersNames: uniformBuffers,
  14378. samplers: samplers,
  14379. defines: defines,
  14380. maxSimultaneousLights: 4
  14381. });
  14382. var join = defines.toString();
  14383. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14384. attributes: attribs,
  14385. uniformsNames: uniforms,
  14386. uniformBuffersNames: uniformBuffers,
  14387. samplers: samplers,
  14388. defines: join,
  14389. fallbacks: null,
  14390. onCompiled: this.onCompiled,
  14391. onError: this.onError,
  14392. indexParameters: { maxSimultaneousLights: 4 }
  14393. }, engine));
  14394. }
  14395. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14396. return false;
  14397. }
  14398. defines._renderId = scene.getRenderId();
  14399. this._wasPreviouslyReady = true;
  14400. return true;
  14401. };
  14402. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14403. var scene = this.getScene();
  14404. var defines = subMesh._materialDefines;
  14405. if (!defines) {
  14406. return;
  14407. }
  14408. var effect = subMesh.effect;
  14409. if (!effect) {
  14410. return;
  14411. }
  14412. this._activeEffect = effect;
  14413. // Matrices
  14414. this.bindOnlyWorldMatrix(world);
  14415. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14416. if (this._mustRebind(scene, effect)) {
  14417. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14418. if (defines.INNERGLOW) {
  14419. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14420. }
  14421. if (defines.BORDER) {
  14422. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14423. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14424. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14425. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14426. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14427. }
  14428. if (defines.HOVERLIGHT) {
  14429. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14430. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14431. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14432. }
  14433. if (defines.TEXTURE) {
  14434. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14435. }
  14436. }
  14437. this._afterBind(mesh, this._activeEffect);
  14438. };
  14439. FluentMaterial.prototype.getActiveTextures = function () {
  14440. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14441. return activeTextures;
  14442. };
  14443. FluentMaterial.prototype.hasTexture = function (texture) {
  14444. if (_super.prototype.hasTexture.call(this, texture)) {
  14445. return true;
  14446. }
  14447. return false;
  14448. };
  14449. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14450. _super.prototype.dispose.call(this, forceDisposeEffect);
  14451. };
  14452. FluentMaterial.prototype.clone = function (name) {
  14453. var _this = this;
  14454. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14455. };
  14456. FluentMaterial.prototype.serialize = function () {
  14457. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14458. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14459. return serializationObject;
  14460. };
  14461. FluentMaterial.prototype.getClassName = function () {
  14462. return "FluentMaterial";
  14463. };
  14464. // Statics
  14465. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14466. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14467. };
  14468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14469. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14470. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14471. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14472. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14473. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14474. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14475. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14476. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14477. ], FluentMaterial.prototype, "alpha", void 0);
  14478. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14479. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14480. ], FluentMaterial.prototype, "albedoColor", void 0);
  14481. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14482. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14483. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14484. ], FluentMaterial.prototype, "renderBorders", void 0);
  14485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14486. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14487. ], FluentMaterial.prototype, "borderWidth", void 0);
  14488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14489. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14490. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14492. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14493. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14495. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14496. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14497. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14498. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14499. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14500. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14501. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14502. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14503. ], FluentMaterial.prototype, "hoverColor", void 0);
  14504. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14505. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14506. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14507. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14508. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14509. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14510. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14511. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14512. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14513. return FluentMaterial;
  14514. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14515. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14516. /***/ }),
  14517. /***/ "./3D/materials/index.ts":
  14518. /*!*******************************!*\
  14519. !*** ./3D/materials/index.ts ***!
  14520. \*******************************/
  14521. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14523. "use strict";
  14524. __webpack_require__.r(__webpack_exports__);
  14525. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14528. /***/ }),
  14529. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14530. /*!*************************************************!*\
  14531. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14532. \*************************************************/
  14533. /*! exports provided: fluentPixelShader */
  14534. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14535. "use strict";
  14536. __webpack_require__.r(__webpack_exports__);
  14537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14538. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs");
  14539. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14540. var name = 'fluentPixelShader';
  14541. 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}";
  14542. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14543. /** @hidden */
  14544. var fluentPixelShader = { name: name, shader: shader };
  14545. /***/ }),
  14546. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14547. /*!***********************************************!*\
  14548. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14549. \***********************************************/
  14550. /*! exports provided: fluentVertexShader */
  14551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14552. "use strict";
  14553. __webpack_require__.r(__webpack_exports__);
  14554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14555. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs");
  14556. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14557. var name = 'fluentVertexShader';
  14558. 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";
  14559. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14560. /** @hidden */
  14561. var fluentVertexShader = { name: name, shader: shader };
  14562. /***/ }),
  14563. /***/ "./3D/vector3WithInfo.ts":
  14564. /*!*******************************!*\
  14565. !*** ./3D/vector3WithInfo.ts ***!
  14566. \*******************************/
  14567. /*! exports provided: Vector3WithInfo */
  14568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14569. "use strict";
  14570. __webpack_require__.r(__webpack_exports__);
  14571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14572. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14573. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs");
  14574. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14575. /**
  14576. * Class used to transport Vector3 information for pointer events
  14577. */
  14578. var Vector3WithInfo = /** @class */ (function (_super) {
  14579. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14580. /**
  14581. * Creates a new Vector3WithInfo
  14582. * @param source defines the vector3 data to transport
  14583. * @param buttonIndex defines the current mouse button index
  14584. */
  14585. function Vector3WithInfo(source,
  14586. /** defines the current mouse button index */
  14587. buttonIndex) {
  14588. if (buttonIndex === void 0) { buttonIndex = 0; }
  14589. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14590. _this.buttonIndex = buttonIndex;
  14591. return _this;
  14592. }
  14593. return Vector3WithInfo;
  14594. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14595. /***/ }),
  14596. /***/ "./index.ts":
  14597. /*!******************!*\
  14598. !*** ./index.ts ***!
  14599. \******************/
  14600. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14602. "use strict";
  14603. __webpack_require__.r(__webpack_exports__);
  14604. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14644. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14661. /***/ }),
  14662. /***/ "./legacy/legacy.ts":
  14663. /*!**************************!*\
  14664. !*** ./legacy/legacy.ts ***!
  14665. \**************************/
  14666. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14668. "use strict";
  14669. __webpack_require__.r(__webpack_exports__);
  14670. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14726. /**
  14727. * Legacy support, defining window.BABYLON.GUI (global variable).
  14728. *
  14729. * This is the entry point for the UMD module.
  14730. * The entry point for a future ESM package should be index.ts
  14731. */
  14732. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14733. if (typeof globalObject !== "undefined") {
  14734. globalObject.BABYLON = globalObject.BABYLON || {};
  14735. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14736. }
  14737. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14738. /***/ }),
  14739. /***/ "babylonjs":
  14740. /*!****************************************************************************************************!*\
  14741. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14742. \****************************************************************************************************/
  14743. /*! no static exports found */
  14744. /***/ (function(module, exports) {
  14745. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs__;
  14746. /***/ })
  14747. /******/ });
  14748. });
  14749. //# sourceMappingURL=babylon.gui.js.map